aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-04-05 16:10:57 +0300
committerEli Zaretskii2013-04-05 16:10:57 +0300
commiteb1dd42a729ab1b9cdcd278767951679480cd4c3 (patch)
tree7a9787eacf9fa495ad8f7caef59bb58a46fbe04a /src
parent86e9346005b957ddadb73586c9641e68ea12a79d (diff)
parent2a417372c4a06fe90c343bc59660268c7a5ac3e9 (diff)
downloademacs-eb1dd42a729ab1b9cdcd278767951679480cd4c3.tar.gz
emacs-eb1dd42a729ab1b9cdcd278767951679480cd4c3.zip
Merge from trunk.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog37
-rw-r--r--src/ChangeLog.102
-rw-r--r--src/alloc.c4
-rw-r--r--src/ccl.c4
-rw-r--r--src/character.c6
-rw-r--r--src/charset.c2
-rw-r--r--src/data.c4
-rw-r--r--src/dired.c5
-rw-r--r--src/dispnew.c4
-rw-r--r--src/doc.c2
-rw-r--r--src/doprnt.c2
-rw-r--r--src/editfns.c6
-rw-r--r--src/fileio.c2
-rw-r--r--src/fns.c12
-rw-r--r--src/font.c4
-rw-r--r--src/frame.c9
-rw-r--r--src/gtkutil.c2
-rw-r--r--src/indent.c2
-rw-r--r--src/keymap.c2
-rw-r--r--src/lisp.h4
-rw-r--r--src/lread.c12
-rw-r--r--src/minibuf.c2
-rw-r--r--src/nsmenu.m2
-rw-r--r--src/process.c2
-rw-r--r--src/search.c6
-rw-r--r--src/w32term.c2
-rw-r--r--src/window.c2
-rw-r--r--src/xdisp.c2
-rw-r--r--src/xsmfns.c2
29 files changed, 92 insertions, 55 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b2b4aa6895c..ea4e660ed8d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,40 @@
12013-04-02 Paul Eggert <eggert@cs.ucla.edu>
2
3 Prefer < to > in range checks such as 0 <= i && i < N.
4 This makes it easier to visualize quantities on a number line.
5 This patch doesn't apply to all such range checks,
6 only to the range checks affected by the 2013-03-24 change.
7 This patch reverts most of the 2013-03-24 change.
8 * alloc.c (xpalloc, Fgarbage_collect):
9 * ccl.c (ccl_driver, resolve_symbol_ccl_program):
10 * character.c (string_escape_byte8):
11 * charset.c (read_hex):
12 * data.c (cons_to_unsigned):
13 * dispnew.c (update_frame_1):
14 * doc.c (Fsubstitute_command_keys):
15 * doprnt.c (doprnt):
16 * editfns.c (hi_time, decode_time_components):
17 * fileio.c (file_offset):
18 * fns.c (larger_vector, make_hash_table, Fmake_hash_table):
19 * font.c (font_intern_prop):
20 * frame.c (x_set_alpha):
21 * gtkutil.c (get_utf8_string):
22 * indent.c (check_display_width):
23 * keymap.c (Fkey_description):
24 * lisp.h (FIXNUM_OVERFLOW_P, vcopy):
25 * lread.c (read1):
26 * minibuf.c (read_minibuf_noninteractive):
27 * process.c (wait_reading_process_output):
28 * search.c (Freplace_match):
29 * window.c (get_phys_cursor_glyph):
30 * xdisp.c (redisplay_internal):
31 * xsmfns.c (smc_save_yourself_CB):
32 Prefer < to > for range checks.
33 * dispnew.c (sit_for): Don't mishandle NaNs.
34 This fixes a bug introduced in the 2013-03-24 change.
35 * editfns.c (decode_time_components): Don't hoist comparison.
36 This fixes another bug introduced in the 2013-03-24 change.
37
12013-03-31 Dmitry Antipov <dmantipov@yandex.ru> 382013-03-31 Dmitry Antipov <dmantipov@yandex.ru>
2 39
3 * frame.h (struct frame): Drop scroll_bottom_vpos 40 * frame.h (struct frame): Drop scroll_bottom_vpos
diff --git a/src/ChangeLog.10 b/src/ChangeLog.10
index 508a2a9dd4c..57c1cbf1299 100644
--- a/src/ChangeLog.10
+++ b/src/ChangeLog.10
@@ -1865,7 +1865,7 @@
1865 1865
18662006-10-07 Ralf Angeli <angeli@caeruleus.net> 18662006-10-07 Ralf Angeli <angeli@caeruleus.net>
1867 1867
1868 * w32fns.c (w32_createwindow): Honour left and top positions if 1868 * w32fns.c (w32_createwindow): Honor left and top positions if
1869 supplied explicitly. 1869 supplied explicitly.
1870 1870
18712006-10-06 Kim F. Storm <storm@cua.dk> 18712006-10-06 Kim F. Storm <storm@cua.dk>
diff --git a/src/alloc.c b/src/alloc.c
index 0a7950273f6..7a56c78e2ba 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -779,7 +779,7 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
779 ptrdiff_t nitems_incr_max = n_max - n; 779 ptrdiff_t nitems_incr_max = n_max - n;
780 ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max)); 780 ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max));
781 781
782 eassert (item_size > 0 && nitems_incr_min > 0 && n >= 0 && nitems_max >= -1); 782 eassert (0 < item_size && 0 < nitems_incr_min && 0 <= n && -1 <= nitems_max);
783 if (! pa) 783 if (! pa)
784 *nitems = 0; 784 *nitems = 0;
785 if (nitems_incr_max < incr) 785 if (nitems_incr_max < incr)
@@ -5376,7 +5376,7 @@ See Info node `(elisp)Garbage Collection'. */)
5376 double tot = total_bytes_of_live_objects (); 5376 double tot = total_bytes_of_live_objects ();
5377 5377
5378 tot *= XFLOAT_DATA (Vgc_cons_percentage); 5378 tot *= XFLOAT_DATA (Vgc_cons_percentage);
5379 if (tot > 0) 5379 if (0 < tot)
5380 { 5380 {
5381 if (tot < TYPE_MAXIMUM (EMACS_INT)) 5381 if (tot < TYPE_MAXIMUM (EMACS_INT))
5382 gc_relative_threshold = tot; 5382 gc_relative_threshold = tot;
diff --git a/src/ccl.c b/src/ccl.c
index c3b3f5486c4..8fec18296a6 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -1668,7 +1668,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1668 } 1668 }
1669 map = XCDR (map); 1669 map = XCDR (map);
1670 if (! (VECTORP (map) 1670 if (! (VECTORP (map)
1671 && ASIZE (map) > 0 1671 && 0 < ASIZE (map)
1672 && INTEGERP (AREF (map, 0)) 1672 && INTEGERP (AREF (map, 0))
1673 && XINT (AREF (map, 0)) <= op 1673 && XINT (AREF (map, 0)) <= op
1674 && op - XINT (AREF (map, 0)) + 1 < ASIZE (map))) 1674 && op - XINT (AREF (map, 0)) + 1 < ASIZE (map)))
@@ -1867,7 +1867,7 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
1867 return Qnil; 1867 return Qnil;
1868 } 1868 }
1869 1869
1870 if (! (XINT (AREF (result, CCL_HEADER_BUF_MAG)) >= 0 1870 if (! (0 <= XINT (AREF (result, CCL_HEADER_BUF_MAG))
1871 && ASCENDING_ORDER (0, XINT (AREF (result, CCL_HEADER_EOF)), 1871 && ASCENDING_ORDER (0, XINT (AREF (result, CCL_HEADER_EOF)),
1872 ASIZE (ccl)))) 1872 ASIZE (ccl))))
1873 return Qnil; 1873 return Qnil;
diff --git a/src/character.c b/src/character.c
index 5a06c7f4d6c..b2caaa290af 100644
--- a/src/character.c
+++ b/src/character.c
@@ -833,8 +833,8 @@ string_escape_byte8 (Lisp_Object string)
833 833
834 if (multibyte) 834 if (multibyte)
835 { 835 {
836 if (byte8_count > (MOST_POSITIVE_FIXNUM - nchars) / 3 836 if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count
837 || byte8_count > (STRING_BYTES_BOUND - nbytes) / 2) 837 || (STRING_BYTES_BOUND - nbytes) / 2 < byte8_count)
838 string_overflow (); 838 string_overflow ();
839 839
840 /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */ 840 /* Convert 2-byte sequence of byte8 chars to 4-byte octal. */
@@ -843,7 +843,7 @@ string_escape_byte8 (Lisp_Object string)
843 } 843 }
844 else 844 else
845 { 845 {
846 if (byte8_count > (STRING_BYTES_BOUND - nbytes) / 3) 846 if ((STRING_BYTES_BOUND - nbytes) / 3 < byte8_count)
847 string_overflow (); 847 string_overflow ();
848 848
849 /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ 849 /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */
diff --git a/src/charset.c b/src/charset.c
index 3d43d81877f..fdb8eebde8b 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -447,7 +447,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
447 n = 0; 447 n = 0;
448 while (c_isxdigit (c = getc (fp))) 448 while (c_isxdigit (c = getc (fp)))
449 { 449 {
450 if (n > UINT_MAX >> 4) 450 if (UINT_MAX >> 4 < n)
451 *overflow = 1; 451 *overflow = 1;
452 n = ((n << 4) 452 n = ((n << 4)
453 | (c - ('0' <= c && c <= '9' ? '0' 453 | (c - ('0' <= c && c <= '9' ? '0'
diff --git a/src/data.c b/src/data.c
index b20d1b4c8af..6622088b648 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2337,13 +2337,13 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
2337 uintmax_t val IF_LINT (= 0); 2337 uintmax_t val IF_LINT (= 0);
2338 if (INTEGERP (c)) 2338 if (INTEGERP (c))
2339 { 2339 {
2340 valid = XINT (c) >= 0; 2340 valid = 0 <= XINT (c);
2341 val = XINT (c); 2341 val = XINT (c);
2342 } 2342 }
2343 else if (FLOATP (c)) 2343 else if (FLOATP (c))
2344 { 2344 {
2345 double d = XFLOAT_DATA (c); 2345 double d = XFLOAT_DATA (c);
2346 if (d >= 0 2346 if (0 <= d
2347 && d < (max == UINTMAX_MAX ? (double) UINTMAX_MAX + 1 : max + 1)) 2347 && d < (max == UINTMAX_MAX ? (double) UINTMAX_MAX + 1 : max + 1))
2348 { 2348 {
2349 val = d; 2349 val = d;
diff --git a/src/dired.c b/src/dired.c
index ab48488966b..7bbfee7e5b0 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -517,8 +517,9 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
517 517
518 QUIT; 518 QUIT;
519 if (len < SCHARS (encoded_file) 519 if (len < SCHARS (encoded_file)
520 || scmp (dp->d_name, SSDATA (encoded_file), 520 || (scmp (dp->d_name, SSDATA (encoded_file),
521 SCHARS (encoded_file)) >= 0) 521 SCHARS (encoded_file))
522 >= 0))
522 continue; 523 continue;
523 524
524 if (file_name_completion_stat (fd, dp, &st) < 0) 525 if (file_name_completion_stat (fd, dp, &st) < 0)
diff --git a/src/dispnew.c b/src/dispnew.c
index 836c0f91020..b4ca654a8f7 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -4506,7 +4506,7 @@ update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
4506 } 4506 }
4507 } 4507 }
4508 4508
4509 lint_assume (FRAME_LINES (f) >= 0); 4509 lint_assume (0 <= FRAME_LINES (f));
4510 pause_p = 0 < i && i < FRAME_LINES (f) - 1; 4510 pause_p = 0 < i && i < FRAME_LINES (f) - 1;
4511 4511
4512 /* Now just clean up termcap drivers and set cursor, etc. */ 4512 /* Now just clean up termcap drivers and set cursor, etc. */
@@ -5772,7 +5772,7 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
5772 else if (FLOATP (timeout)) 5772 else if (FLOATP (timeout))
5773 { 5773 {
5774 double seconds = XFLOAT_DATA (timeout); 5774 double seconds = XFLOAT_DATA (timeout);
5775 if (seconds <= 0) 5775 if (! (0 < seconds))
5776 return Qt; 5776 return Qt;
5777 else 5777 else
5778 { 5778 {
diff --git a/src/doc.c b/src/doc.c
index 1ddaa117bba..7234fb38bf9 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -826,7 +826,7 @@ Otherwise, return a new string, without any text properties. */)
826 if (NILP (tem)) /* but not on any keys */ 826 if (NILP (tem)) /* but not on any keys */
827 { 827 {
828 ptrdiff_t offset = bufp - buf; 828 ptrdiff_t offset = bufp - buf;
829 if (bsize > STRING_BYTES_BOUND - 4) 829 if (STRING_BYTES_BOUND - 4 < bsize)
830 string_overflow (); 830 string_overflow ();
831 buf = xrealloc (buf, bsize += 4); 831 buf = xrealloc (buf, bsize += 4);
832 bufp = buf + offset; 832 bufp = buf + offset;
diff --git a/src/doprnt.c b/src/doprnt.c
index 087256ced2a..471e35c7b43 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -361,7 +361,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
361 361
362 /* Copy string into final output, truncating if no room. */ 362 /* Copy string into final output, truncating if no room. */
363 doit: 363 doit:
364 eassert (tem >= 0); 364 eassert (0 <= tem);
365 /* Coming here means STRING contains ASCII only. */ 365 /* Coming here means STRING contains ASCII only. */
366 if (STRING_BYTES_BOUND < tem) 366 if (STRING_BYTES_BOUND < tem)
367 error ("Format width or precision too large"); 367 error ("Format width or precision too large");
diff --git a/src/editfns.c b/src/editfns.c
index d0cca6f3d7b..e0b0347fe69 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1398,8 +1398,8 @@ hi_time (time_t t)
1398 no runtime check is needed, and taking care not to convert 1398 no runtime check is needed, and taking care not to convert
1399 negative numbers to unsigned before comparing them. */ 1399 negative numbers to unsigned before comparing them. */
1400 if (! ((! TYPE_SIGNED (time_t) 1400 if (! ((! TYPE_SIGNED (time_t)
1401 || TIME_T_MIN >> 16 >= MOST_NEGATIVE_FIXNUM 1401 || MOST_NEGATIVE_FIXNUM <= TIME_T_MIN >> 16
1402 || hi >= MOST_NEGATIVE_FIXNUM) 1402 || MOST_NEGATIVE_FIXNUM <= hi)
1403 && (TIME_T_MAX >> 16 <= MOST_POSITIVE_FIXNUM 1403 && (TIME_T_MAX >> 16 <= MOST_POSITIVE_FIXNUM
1404 || hi <= MOST_POSITIVE_FIXNUM))) 1404 || hi <= MOST_POSITIVE_FIXNUM)))
1405 time_overflow (); 1405 time_overflow ();
@@ -1561,7 +1561,7 @@ decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec,
1561 1561
1562 if (result) 1562 if (result)
1563 { 1563 {
1564 if (hi >= (TYPE_SIGNED (time_t) ? TIME_T_MIN >> 16 : 0) 1564 if ((TYPE_SIGNED (time_t) ? TIME_T_MIN >> 16 <= hi : 0 <= hi)
1565 && hi <= TIME_T_MAX >> 16) 1565 && hi <= TIME_T_MAX >> 16)
1566 { 1566 {
1567 /* Return the greatest representable time that is not greater 1567 /* Return the greatest representable time that is not greater
diff --git a/src/fileio.c b/src/fileio.c
index d7c476172cb..2047338f03e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3449,7 +3449,7 @@ file_offset (Lisp_Object val)
3449 if (FLOATP (val)) 3449 if (FLOATP (val))
3450 { 3450 {
3451 double v = XFLOAT_DATA (val); 3451 double v = XFLOAT_DATA (val);
3452 if (v >= 0 3452 if (0 <= v
3453 && (sizeof (off_t) < sizeof v 3453 && (sizeof (off_t) < sizeof v
3454 ? v <= TYPE_MAXIMUM (off_t) 3454 ? v <= TYPE_MAXIMUM (off_t)
3455 : v < TYPE_MAXIMUM (off_t))) 3455 : v < TYPE_MAXIMUM (off_t)))
diff --git a/src/fns.c b/src/fns.c
index 82ce933b25d..b3a1dc2317a 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3409,7 +3409,7 @@ larger_vector (Lisp_Object vec, ptrdiff_t incr_min, ptrdiff_t nitems_max)
3409 ptrdiff_t n_max = (0 <= nitems_max && nitems_max < C_language_max 3409 ptrdiff_t n_max = (0 <= nitems_max && nitems_max < C_language_max
3410 ? nitems_max : C_language_max); 3410 ? nitems_max : C_language_max);
3411 eassert (VECTORP (vec)); 3411 eassert (VECTORP (vec));
3412 eassert (incr_min > 0 && nitems_max >= -1); 3412 eassert (0 < incr_min && -1 <= nitems_max);
3413 old_size = ASIZE (vec); 3413 old_size = ASIZE (vec);
3414 incr_max = n_max - old_size; 3414 incr_max = n_max - old_size;
3415 incr = max (incr_min, min (old_size >> 1, incr_max)); 3415 incr = max (incr_min, min (old_size >> 1, incr_max));
@@ -3574,9 +3574,9 @@ make_hash_table (struct hash_table_test test,
3574 eassert (SYMBOLP (test.name)); 3574 eassert (SYMBOLP (test.name));
3575 eassert (INTEGERP (size) && XINT (size) >= 0); 3575 eassert (INTEGERP (size) && XINT (size) >= 0);
3576 eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0) 3576 eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0)
3577 || (FLOATP (rehash_size) && XFLOAT_DATA (rehash_size) > 1)); 3577 || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size)));
3578 eassert (FLOATP (rehash_threshold) 3578 eassert (FLOATP (rehash_threshold)
3579 && XFLOAT_DATA (rehash_threshold) > 0 3579 && 0 < XFLOAT_DATA (rehash_threshold)
3580 && XFLOAT_DATA (rehash_threshold) <= 1.0); 3580 && XFLOAT_DATA (rehash_threshold) <= 1.0);
3581 3581
3582 if (XFASTINT (size) == 0) 3582 if (XFASTINT (size) == 0)
@@ -4312,15 +4312,15 @@ usage: (make-hash-table &rest KEYWORD-ARGS) */)
4312 /* Look for `:rehash-size SIZE'. */ 4312 /* Look for `:rehash-size SIZE'. */
4313 i = get_key_arg (QCrehash_size, nargs, args, used); 4313 i = get_key_arg (QCrehash_size, nargs, args, used);
4314 rehash_size = i ? args[i] : make_float (DEFAULT_REHASH_SIZE); 4314 rehash_size = i ? args[i] : make_float (DEFAULT_REHASH_SIZE);
4315 if (! ((INTEGERP (rehash_size) && XINT (rehash_size) > 0) 4315 if (! ((INTEGERP (rehash_size) && 0 < XINT (rehash_size))
4316 || (FLOATP (rehash_size) && XFLOAT_DATA (rehash_size) > 1))) 4316 || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size))))
4317 signal_error ("Invalid hash table rehash size", rehash_size); 4317 signal_error ("Invalid hash table rehash size", rehash_size);
4318 4318
4319 /* Look for `:rehash-threshold THRESHOLD'. */ 4319 /* Look for `:rehash-threshold THRESHOLD'. */
4320 i = get_key_arg (QCrehash_threshold, nargs, args, used); 4320 i = get_key_arg (QCrehash_threshold, nargs, args, used);
4321 rehash_threshold = i ? args[i] : make_float (DEFAULT_REHASH_THRESHOLD); 4321 rehash_threshold = i ? args[i] : make_float (DEFAULT_REHASH_THRESHOLD);
4322 if (! (FLOATP (rehash_threshold) 4322 if (! (FLOATP (rehash_threshold)
4323 && XFLOAT_DATA (rehash_threshold) > 0 4323 && 0 < XFLOAT_DATA (rehash_threshold)
4324 && XFLOAT_DATA (rehash_threshold) <= 1)) 4324 && XFLOAT_DATA (rehash_threshold) <= 1))
4325 signal_error ("Invalid hash table rehash threshold", rehash_threshold); 4325 signal_error ("Invalid hash table rehash threshold", rehash_threshold);
4326 4326
diff --git a/src/font.c b/src/font.c
index d66620bffbc..0b0144f3197 100644
--- a/src/font.c
+++ b/src/font.c
@@ -229,7 +229,7 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
229 229
230 if (len == 1 && *str == '*') 230 if (len == 1 && *str == '*')
231 return Qnil; 231 return Qnil;
232 if (!force_symbol && len > 0 && '0' <= *str && *str <= '9') 232 if (!force_symbol && 0 < len && '0' <= *str && *str <= '9')
233 { 233 {
234 for (i = 1; i < len; i++) 234 for (i = 1; i < len; i++)
235 if (! ('0' <= str[i] && str[i] <= '9')) 235 if (! ('0' <= str[i] && str[i] <= '9'))
@@ -243,7 +243,7 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
243 { 243 {
244 if (i == len) 244 if (i == len)
245 return make_number (n); 245 return make_number (n);
246 if (n > MOST_POSITIVE_FIXNUM / 10) 246 if (MOST_POSITIVE_FIXNUM / 10 < n)
247 break; 247 break;
248 } 248 }
249 249
diff --git a/src/frame.c b/src/frame.c
index 970e40b5175..0aeaf4cf417 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -889,7 +889,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
889/* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the 889/* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
890 same tty (for tty frames) or among frames which uses FRAME's keyboard. 890 same tty (for tty frames) or among frames which uses FRAME's keyboard.
891 If MINIBUF is nil, do not consider minibuffer-only candidate. 891 If MINIBUF is nil, do not consider minibuffer-only candidate.
892 If MINIBUF is `visible', do not consider an invisible candidate. 892 If MINIBUF is `visible', do not consider an invisible candidate.
893 If MINIBUF is a window, consider only its own frame and candidate now 893 If MINIBUF is a window, consider only its own frame and candidate now
894 using that window as the minibuffer. 894 using that window as the minibuffer.
895 If MINIBUF is 0, consider candidate if it is visible or iconified. 895 If MINIBUF is 0, consider candidate if it is visible or iconified.
@@ -3311,16 +3311,15 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
3311 else if (FLOATP (item)) 3311 else if (FLOATP (item))
3312 { 3312 {
3313 alpha = XFLOAT_DATA (item); 3313 alpha = XFLOAT_DATA (item);
3314 if (alpha < 0.0 || alpha > 1.0) 3314 if (! (0 <= alpha && alpha <= 1.0))
3315 args_out_of_range (make_float (0.0), make_float (1.0)); 3315 args_out_of_range (make_float (0.0), make_float (1.0));
3316 } 3316 }
3317 else if (INTEGERP (item)) 3317 else if (INTEGERP (item))
3318 { 3318 {
3319 EMACS_INT ialpha = XINT (item); 3319 EMACS_INT ialpha = XINT (item);
3320 if (ialpha < 0 || ialpha > 100) 3320 if (! (0 <= ialpha && alpha <= 100))
3321 args_out_of_range (make_number (0), make_number (100)); 3321 args_out_of_range (make_number (0), make_number (100));
3322 else 3322 alpha = ialpha / 100.0;
3323 alpha = ialpha / 100.0;
3324 } 3323 }
3325 else 3324 else
3326 wrong_type_argument (Qnumberp, item); 3325 wrong_type_argument (Qnumberp, item);
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 595a7427c21..f83d8660fcc 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -543,7 +543,7 @@ get_utf8_string (const char *str)
543 if (cp) g_free (cp); 543 if (cp) g_free (cp);
544 544
545 len = strlen (str); 545 len = strlen (str);
546 if (nr_bad > (min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4) 546 if ((min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4 < nr_bad)
547 memory_full (SIZE_MAX); 547 memory_full (SIZE_MAX);
548 up = utf8_str = xmalloc (len + nr_bad * 4 + 1); 548 up = utf8_str = xmalloc (len + nr_bad * 4 + 1);
549 p = (unsigned char *)str; 549 p = (unsigned char *)str;
diff --git a/src/indent.c b/src/indent.c
index 345dfaa9ce3..67796ab8a8f 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -466,7 +466,7 @@ check_display_width (ptrdiff_t pos, ptrdiff_t col, ptrdiff_t *endpos)
466 if ((prop = Fplist_get (plist, QCwidth), 466 if ((prop = Fplist_get (plist, QCwidth),
467 RANGED_INTEGERP (0, prop, INT_MAX))) 467 RANGED_INTEGERP (0, prop, INT_MAX)))
468 width = XINT (prop); 468 width = XINT (prop);
469 else if (FLOATP (prop) && XFLOAT_DATA (prop) >= 0 469 else if (FLOATP (prop) && 0 <= XFLOAT_DATA (prop)
470 && XFLOAT_DATA (prop) <= INT_MAX) 470 && XFLOAT_DATA (prop) <= INT_MAX)
471 width = (int)(XFLOAT_DATA (prop) + 0.5); 471 width = (int)(XFLOAT_DATA (prop) + 0.5);
472 else if ((prop = Fplist_get (plist, QCalign_to), 472 else if ((prop = Fplist_get (plist, QCalign_to),
diff --git a/src/keymap.c b/src/keymap.c
index e759214fa33..c43d528b25b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -2063,7 +2063,7 @@ For an approximate inverse of this, see `kbd'. */)
2063 size += XINT (Flength (prefix)); 2063 size += XINT (Flength (prefix));
2064 2064
2065 /* This has one extra element at the end that we don't pass to Fconcat. */ 2065 /* This has one extra element at the end that we don't pass to Fconcat. */
2066 if (size > min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4) 2066 if (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size)
2067 memory_full (SIZE_MAX); 2067 memory_full (SIZE_MAX);
2068 SAFE_ALLOCA_LISP (args, size * 4); 2068 SAFE_ALLOCA_LISP (args, size * 4);
2069 2069
diff --git a/src/lisp.h b/src/lisp.h
index 4481a2e3373..82cf0cb2678 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -543,7 +543,7 @@ static EMACS_INT const VALMASK
543 type or if I is a NaN. */ 543 type or if I is a NaN. */
544 544
545#define FIXNUM_OVERFLOW_P(i) \ 545#define FIXNUM_OVERFLOW_P(i) \
546 (! (((i) >= 0 || (i) >= MOST_NEGATIVE_FIXNUM) && (i) <= MOST_POSITIVE_FIXNUM)) 546 (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM))
547 547
548LISP_INLINE ptrdiff_t 548LISP_INLINE ptrdiff_t
549clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) 549clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
@@ -2560,7 +2560,7 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
2560LISP_INLINE void 2560LISP_INLINE void
2561vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count) 2561vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count)
2562{ 2562{
2563 eassert (offset >= 0 && count >= 0 && offset + count <= ASIZE (v)); 2563 eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
2564 memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args); 2564 memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
2565} 2565}
2566 2566
diff --git a/src/lread.c b/src/lread.c
index d7a16f813c8..8e623e838c7 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2636,7 +2636,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2636 nskip--; 2636 nskip--;
2637 else 2637 else
2638 UNREAD (c); 2638 UNREAD (c);
2639 2639
2640 if (load_force_doc_strings 2640 if (load_force_doc_strings
2641 && (FROM_FILE_P (readcharfun))) 2641 && (FROM_FILE_P (readcharfun)))
2642 { 2642 {
@@ -2731,8 +2731,8 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2731 /* Read a non-negative integer. */ 2731 /* Read a non-negative integer. */
2732 while (c >= '0' && c <= '9') 2732 while (c >= '0' && c <= '9')
2733 { 2733 {
2734 if (n > MOST_POSITIVE_FIXNUM / 10 2734 if (MOST_POSITIVE_FIXNUM / 10 < n
2735 || n * 10 + c - '0' > MOST_POSITIVE_FIXNUM) 2735 || MOST_POSITIVE_FIXNUM < n * 10 + c - '0')
2736 n = MOST_POSITIVE_FIXNUM + 1; 2736 n = MOST_POSITIVE_FIXNUM + 1;
2737 else 2737 else
2738 n = n * 10 + c - '0'; 2738 n = n * 10 + c - '0';
@@ -2930,7 +2930,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
2930 if (end - p < MAX_MULTIBYTE_LENGTH) 2930 if (end - p < MAX_MULTIBYTE_LENGTH)
2931 { 2931 {
2932 ptrdiff_t offset = p - read_buffer; 2932 ptrdiff_t offset = p - read_buffer;
2933 if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2) 2933 if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
2934 memory_full (SIZE_MAX); 2934 memory_full (SIZE_MAX);
2935 read_buffer = xrealloc (read_buffer, read_buffer_size * 2); 2935 read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
2936 read_buffer_size *= 2; 2936 read_buffer_size *= 2;
@@ -3064,7 +3064,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3064 if (end - p < MAX_MULTIBYTE_LENGTH) 3064 if (end - p < MAX_MULTIBYTE_LENGTH)
3065 { 3065 {
3066 ptrdiff_t offset = p - read_buffer; 3066 ptrdiff_t offset = p - read_buffer;
3067 if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2) 3067 if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
3068 memory_full (SIZE_MAX); 3068 memory_full (SIZE_MAX);
3069 read_buffer = xrealloc (read_buffer, read_buffer_size * 2); 3069 read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
3070 read_buffer_size *= 2; 3070 read_buffer_size *= 2;
@@ -3094,7 +3094,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
3094 if (p == end) 3094 if (p == end)
3095 { 3095 {
3096 ptrdiff_t offset = p - read_buffer; 3096 ptrdiff_t offset = p - read_buffer;
3097 if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2) 3097 if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
3098 memory_full (SIZE_MAX); 3098 memory_full (SIZE_MAX);
3099 read_buffer = xrealloc (read_buffer, read_buffer_size * 2); 3099 read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
3100 read_buffer_size *= 2; 3100 read_buffer_size *= 2;
diff --git a/src/minibuf.c b/src/minibuf.c
index 75e54789912..68c39310f01 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -251,7 +251,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
251 { 251 {
252 if (len == size) 252 if (len == size)
253 { 253 {
254 if (size > STRING_BYTES_BOUND / 2) 254 if (STRING_BYTES_BOUND / 2 < size)
255 memory_full (SIZE_MAX); 255 memory_full (SIZE_MAX);
256 size *= 2; 256 size *= 2;
257 line = xrealloc (line, size); 257 line = xrealloc (line, size);
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 4e26a994b59..15878dc74d7 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -508,7 +508,7 @@ void
508x_activate_menubar (struct frame *f) 508x_activate_menubar (struct frame *f)
509{ 509{
510 NSArray *a = [[NSApp mainMenu] itemArray]; 510 NSArray *a = [[NSApp mainMenu] itemArray];
511 /* Update each submenu separatly so ns_update_menubar don't reset 511 /* Update each submenu separately so ns_update_menubar doesn't reset
512 the delegate. */ 512 the delegate. */
513 int i = 0; 513 int i = 0;
514 while (i < [a count]) 514 while (i < [a count])
diff --git a/src/process.c b/src/process.c
index 6a14a536707..911a30bc808 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4236,7 +4236,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4236 time_limit = 0; 4236 time_limit = 0;
4237 nsecs = -1; 4237 nsecs = -1;
4238 } 4238 }
4239 else if (time_limit > TYPE_MAXIMUM (time_t)) 4239 else if (TYPE_MAXIMUM (time_t) < time_limit)
4240 time_limit = TYPE_MAXIMUM (time_t); 4240 time_limit = TYPE_MAXIMUM (time_t);
4241 4241
4242 /* Since we may need to wait several times, 4242 /* Since we may need to wait several times,
diff --git a/src/search.c b/src/search.c
index ece346ecd06..ea36133deb7 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2533,9 +2533,9 @@ since only regular expressions have distinguished subexpressions. */)
2533 bool str_multibyte = STRING_MULTIBYTE (newtext); 2533 bool str_multibyte = STRING_MULTIBYTE (newtext);
2534 bool really_changed = 0; 2534 bool really_changed = 0;
2535 2535
2536 substed_alloc_size = (length > (STRING_BYTES_BOUND - 100) / 2 2536 substed_alloc_size = (length <= (STRING_BYTES_BOUND - 100) / 2
2537 ? STRING_BYTES_BOUND 2537 ? length * 2 + 100
2538 : length * 2 + 100); 2538 : STRING_BYTES_BOUND);
2539 substed = xmalloc (substed_alloc_size); 2539 substed = xmalloc (substed_alloc_size);
2540 substed_len = 0; 2540 substed_len = 0;
2541 2541
diff --git a/src/w32term.c b/src/w32term.c
index 5f7952c2ec2..d249d6e3252 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -5694,7 +5694,7 @@ w32fullscreen_hook (FRAME_PTR f)
5694 /* Need to send SC_RESTORE to the window, in case we are 5694 /* Need to send SC_RESTORE to the window, in case we are
5695 resizing from FULLSCREEN_MAXIMIZED. Otherwise, the mouse 5695 resizing from FULLSCREEN_MAXIMIZED. Otherwise, the mouse
5696 resize hints will not be shown by the window manager when the 5696 resize hints will not be shown by the window manager when the
5697 mouse pointer hovers over the window edges, becaise the WM 5697 mouse pointer hovers over the window edges, because the WM
5698 will still think the window is maximized. */ 5698 will still think the window is maximized. */
5699 if (f->want_fullscreen != FULLSCREEN_BOTH) 5699 if (f->want_fullscreen != FULLSCREEN_BOTH)
5700 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_RESTORE, 0); 5700 SendMessage (FRAME_W32_WINDOW (f), WM_SYSCOMMAND, SC_RESTORE, 0);
diff --git a/src/window.c b/src/window.c
index b66111a5605..feb5f7b5cc7 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5944,7 +5944,7 @@ get_phys_cursor_glyph (struct window *w)
5944 hpos = row->used[TEXT_AREA] - 1; 5944 hpos = row->used[TEXT_AREA] - 1;
5945 } 5945 }
5946 5946
5947 if (hpos >= 0 && hpos < row->used[TEXT_AREA]) 5947 if (0 <= hpos && hpos < row->used[TEXT_AREA])
5948 glyph = row->glyphs[TEXT_AREA] + hpos; 5948 glyph = row->glyphs[TEXT_AREA] + hpos;
5949 else 5949 else
5950 glyph = NULL; 5950 glyph = NULL;
diff --git a/src/xdisp.c b/src/xdisp.c
index a7be5fc275c..41214880a56 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13168,7 +13168,7 @@ redisplay_internal (void)
13168 PT == w->last_point 13168 PT == w->last_point
13169 /* Make sure the cursor was last displayed 13169 /* Make sure the cursor was last displayed
13170 in this window. Otherwise we have to reposition it. */ 13170 in this window. Otherwise we have to reposition it. */
13171 && w->cursor.vpos >= 0 13171 && 0 <= w->cursor.vpos
13172 && w->cursor.vpos < WINDOW_TOTAL_LINES (w)) 13172 && w->cursor.vpos < WINDOW_TOTAL_LINES (w))
13173 { 13173 {
13174 if (!must_finish) 13174 if (!must_finish)
diff --git a/src/xsmfns.c b/src/xsmfns.c
index 0af196d2160..cb7122202df 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -221,7 +221,7 @@ smc_save_yourself_CB (SmcConn smcConn,
221 props[props_idx]->name = xstrdup (SmRestartCommand); 221 props[props_idx]->name = xstrdup (SmRestartCommand);
222 props[props_idx]->type = xstrdup (SmLISTofARRAY8); 222 props[props_idx]->type = xstrdup (SmLISTofARRAY8);
223 /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */ 223 /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */
224 if (initial_argc > INT_MAX - 3) 224 if (INT_MAX - 3 < initial_argc)
225 memory_full (SIZE_MAX); 225 memory_full (SIZE_MAX);
226 i = 3 + initial_argc; 226 i = 3 + initial_argc;
227 props[props_idx]->num_vals = i; 227 props[props_idx]->num_vals = i;