]> code.delx.au - gnu-emacs/commitdiff
Prefer < to > in range checks such as 0 <= i && i < N.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 2 Apr 2013 01:54:56 +0000 (18:54 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 2 Apr 2013 01:54:56 +0000 (18:54 -0700)
This makes it easier to visualize quantities on a number line.
This patch doesn't apply to all such range checks,
only to the range checks affected by the 2013-03-24 change.
This patch reverts most of the 2013-03-24 change.
* alloc.c (xpalloc, Fgarbage_collect):
* ccl.c (ccl_driver, resolve_symbol_ccl_program):
* character.c (string_escape_byte8):
* charset.c (read_hex):
* data.c (cons_to_unsigned):
* dispnew.c (update_frame_1):
* doc.c (Fsubstitute_command_keys):
* doprnt.c (doprnt):
* editfns.c (hi_time, decode_time_components):
* fileio.c (file_offset):
* fns.c (larger_vector, make_hash_table, Fmake_hash_table):
* font.c (font_intern_prop):
* frame.c (x_set_alpha):
* gtkutil.c (get_utf8_string):
* indent.c (check_display_width):
* keymap.c (Fkey_description):
* lisp.h (FIXNUM_OVERFLOW_P, vcopy):
* lread.c (read1):
* minibuf.c (read_minibuf_noninteractive):
* process.c (wait_reading_process_output):
* search.c (Freplace_match):
* window.c (get_phys_cursor_glyph):
* xdisp.c (redisplay_internal):
* xsmfns.c (smc_save_yourself_CB):
Prefer < to > for range checks.
* dispnew.c (sit_for): Don't mishandle NaNs.
This fixes a bug introduced in the 2013-03-24 change.
* editfns.c (decode_time_components): Don't hoist comparison.
This fixes another bug introduced in the 2013-03-24 change.

26 files changed:
src/ChangeLog
src/alloc.c
src/ccl.c
src/character.c
src/charset.c
src/data.c
src/dired.c
src/dispnew.c
src/doc.c
src/doprnt.c
src/editfns.c
src/fileio.c
src/fns.c
src/font.c
src/frame.c
src/gtkutil.c
src/indent.c
src/keymap.c
src/lisp.h
src/lread.c
src/minibuf.c
src/process.c
src/search.c
src/window.c
src/xdisp.c
src/xsmfns.c

index b2b4aa6895c6fee7b315bd7a460f1071db7e4290..ea4e660ed8d367807f383062f49695ff99188e56 100644 (file)
@@ -1,3 +1,40 @@
+2013-04-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Prefer < to > in range checks such as 0 <= i && i < N.
+       This makes it easier to visualize quantities on a number line.
+       This patch doesn't apply to all such range checks,
+       only to the range checks affected by the 2013-03-24 change.
+       This patch reverts most of the 2013-03-24 change.
+       * alloc.c (xpalloc, Fgarbage_collect):
+       * ccl.c (ccl_driver, resolve_symbol_ccl_program):
+       * character.c (string_escape_byte8):
+       * charset.c (read_hex):
+       * data.c (cons_to_unsigned):
+       * dispnew.c (update_frame_1):
+       * doc.c (Fsubstitute_command_keys):
+       * doprnt.c (doprnt):
+       * editfns.c (hi_time, decode_time_components):
+       * fileio.c (file_offset):
+       * fns.c (larger_vector, make_hash_table, Fmake_hash_table):
+       * font.c (font_intern_prop):
+       * frame.c (x_set_alpha):
+       * gtkutil.c (get_utf8_string):
+       * indent.c (check_display_width):
+       * keymap.c (Fkey_description):
+       * lisp.h (FIXNUM_OVERFLOW_P, vcopy):
+       * lread.c (read1):
+       * minibuf.c (read_minibuf_noninteractive):
+       * process.c (wait_reading_process_output):
+       * search.c (Freplace_match):
+       * window.c (get_phys_cursor_glyph):
+       * xdisp.c (redisplay_internal):
+       * xsmfns.c (smc_save_yourself_CB):
+       Prefer < to > for range checks.
+       * dispnew.c (sit_for): Don't mishandle NaNs.
+       This fixes a bug introduced in the 2013-03-24 change.
+       * editfns.c (decode_time_components): Don't hoist comparison.
+       This fixes another bug introduced in the 2013-03-24 change.
+
 2013-03-31  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * frame.h (struct frame): Drop scroll_bottom_vpos
index 0a7950273f612dd6af08a62f9a4d8e968fe13ced..7a56c78e2ba4b933acfdc03c915cda80edae28bb 100644 (file)
@@ -779,7 +779,7 @@ xpalloc (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min,
   ptrdiff_t nitems_incr_max = n_max - n;
   ptrdiff_t incr = max (nitems_incr_min, min (incr_estimate, nitems_incr_max));
 
-  eassert (item_size > 0 && nitems_incr_min > 0 && n >= 0 && nitems_max >= -1);
+  eassert (0 < item_size && 0 < nitems_incr_min && 0 <= n && -1 <= nitems_max);
   if (! pa)
     *nitems = 0;
   if (nitems_incr_max < incr)
@@ -5376,7 +5376,7 @@ See Info node `(elisp)Garbage Collection'.  */)
       double tot = total_bytes_of_live_objects ();
 
       tot *= XFLOAT_DATA (Vgc_cons_percentage);
-      if (tot > 0)
+      if (0 < tot)
        {
          if (tot < TYPE_MAXIMUM (EMACS_INT))
            gc_relative_threshold = tot;
index c3b3f5486c422c2b9e2f1a5bee405fdc8da0543e..8fec18296a66f27c68bf43c8c280755ef029da9b 100644 (file)
--- 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
                  }
                map = XCDR (map);
                if (! (VECTORP (map)
-                      && ASIZE (map) > 0
+                      && 0 < ASIZE (map)
                       && INTEGERP (AREF (map, 0))
                       && XINT (AREF (map, 0)) <= op
                       && op - XINT (AREF (map, 0)) + 1 < ASIZE (map)))
@@ -1867,7 +1867,7 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
       return Qnil;
     }
 
-  if (! (XINT (AREF (result, CCL_HEADER_BUF_MAG)) >= 0
+  if (! (0 <= XINT (AREF (result, CCL_HEADER_BUF_MAG))
         && ASCENDING_ORDER (0, XINT (AREF (result, CCL_HEADER_EOF)),
                             ASIZE (ccl))))
     return Qnil;
index 5a06c7f4d6cfe0082c947022190f4bb1ded65b71..b2caaa290af1d5d1eacaded40af19d710c26c09c 100644 (file)
@@ -833,8 +833,8 @@ string_escape_byte8 (Lisp_Object string)
 
   if (multibyte)
     {
-      if (byte8_count > (MOST_POSITIVE_FIXNUM - nchars) / 3
-         || byte8_count > (STRING_BYTES_BOUND - nbytes) / 2)
+      if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count
+         || (STRING_BYTES_BOUND - nbytes) / 2 < byte8_count)
        string_overflow ();
 
       /* Convert 2-byte sequence of byte8 chars to 4-byte octal.  */
@@ -843,7 +843,7 @@ string_escape_byte8 (Lisp_Object string)
     }
   else
     {
-      if (byte8_count > (STRING_BYTES_BOUND - nbytes) / 3)
+      if ((STRING_BYTES_BOUND - nbytes) / 3 < byte8_count)
        string_overflow ();
 
       /* Convert 1-byte sequence of byte8 chars to 4-byte octal.  */
index 3d43d81877fb967810fe21ca5591c44e8ecfb1be..fdb8eebde8b1d3cd712ea70a7490f20035e493d9 100644 (file)
@@ -447,7 +447,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow)
   n = 0;
   while (c_isxdigit (c = getc (fp)))
     {
-      if (n > UINT_MAX >> 4)
+      if (UINT_MAX >> 4 < n)
        *overflow = 1;
       n = ((n << 4)
           | (c - ('0' <= c && c <= '9' ? '0'
index b20d1b4c8afd53567e97e79d8fa6f2238f6cbffd..6622088b648f09b50da8e64a0ee3d0a3fb3a721e 100644 (file)
@@ -2337,13 +2337,13 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
   uintmax_t val IF_LINT (= 0);
   if (INTEGERP (c))
     {
-      valid = XINT (c) >= 0;
+      valid = 0 <= XINT (c);
       val = XINT (c);
     }
   else if (FLOATP (c))
     {
       double d = XFLOAT_DATA (c);
-      if (d >= 0
+      if (0 <= d
          && d < (max == UINTMAX_MAX ? (double) UINTMAX_MAX + 1 : max + 1))
        {
          val = d;
index ab48488966b7cecfc57d728489ade8cd4879034f..7bbfee7e5b0723fba209dbabd1e23037c2a4a478 100644 (file)
@@ -517,8 +517,9 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
 
       QUIT;
       if (len < SCHARS (encoded_file)
-         || scmp (dp->d_name, SSDATA (encoded_file),
-                  SCHARS (encoded_file)) >= 0)
+         || (scmp (dp->d_name, SSDATA (encoded_file),
+                   SCHARS (encoded_file))
+             >= 0))
        continue;
 
       if (file_name_completion_stat (fd, dp, &st) < 0)
index 836c0f91020a8f710ef4c21b2bb96d2ffdd89077..b4ca654a8f7d5b6acff027a8426b565fe93d78bd 100644 (file)
@@ -4506,7 +4506,7 @@ update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p)
        }
     }
 
-  lint_assume (FRAME_LINES (f) >= 0);
+  lint_assume (0 <= FRAME_LINES (f));
   pause_p = 0 < i && i < FRAME_LINES (f) - 1;
 
   /* Now just clean up termcap drivers and set cursor, etc.  */
@@ -5772,7 +5772,7 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
   else if (FLOATP (timeout))
     {
       double seconds = XFLOAT_DATA (timeout);
-      if (seconds <= 0)
+      if (! (0 < seconds))
        return Qt;
       else
        {
index 1ddaa117bba8002d54be395e0990a7105abc4811..7234fb38bf906bb5bcbd0e9a0013429c8aaea684 100644 (file)
--- a/src/doc.c
+++ b/src/doc.c
@@ -826,7 +826,7 @@ Otherwise, return a new string, without any text properties.  */)
          if (NILP (tem))       /* but not on any keys */
            {
              ptrdiff_t offset = bufp - buf;
-             if (bsize > STRING_BYTES_BOUND - 4)
+             if (STRING_BYTES_BOUND - 4 < bsize)
                string_overflow ();
              buf = xrealloc (buf, bsize += 4);
              bufp = buf + offset;
index 087256ced2a1a595b7960bcd78b43401e5ab82b0..471e35c7b43c7c69ff75ffa3008f4a7d95a02125 100644 (file)
@@ -361,7 +361,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format,
 
              /* Copy string into final output, truncating if no room.  */
            doit:
-             eassert (tem >= 0);
+             eassert (0 <= tem);
              /* Coming here means STRING contains ASCII only.  */
              if (STRING_BYTES_BOUND < tem)
                error ("Format width or precision too large");
index d0cca6f3d7b255b0eedc3b452f2e1034646d5007..e0b0347fe69ac53a8a53c99972ad4a24e78befb6 100644 (file)
@@ -1398,8 +1398,8 @@ hi_time (time_t t)
      no runtime check is needed, and taking care not to convert
      negative numbers to unsigned before comparing them.  */
   if (! ((! TYPE_SIGNED (time_t)
-         || TIME_T_MIN >> 16 >= MOST_NEGATIVE_FIXNUM
-         || hi >= MOST_NEGATIVE_FIXNUM)
+         || MOST_NEGATIVE_FIXNUM <= TIME_T_MIN >> 16
+         || MOST_NEGATIVE_FIXNUM <= hi)
         && (TIME_T_MAX >> 16 <= MOST_POSITIVE_FIXNUM
             || hi <= MOST_POSITIVE_FIXNUM)))
     time_overflow ();
@@ -1561,7 +1561,7 @@ decode_time_components (Lisp_Object high, Lisp_Object low, Lisp_Object usec,
 
   if (result)
     {
-      if (hi >= (TYPE_SIGNED (time_t) ? TIME_T_MIN >> 16 : 0)
+      if ((TYPE_SIGNED (time_t) ? TIME_T_MIN >> 16 <= hi : 0 <= hi)
          && hi <= TIME_T_MAX >> 16)
        {
          /* Return the greatest representable time that is not greater
index d7c476172cb0886ffb1cee102549a128eb64a1fe..2047338f03eafcc54c97cf9377dfd0b9942423ab 100644 (file)
@@ -3449,7 +3449,7 @@ file_offset (Lisp_Object val)
   if (FLOATP (val))
     {
       double v = XFLOAT_DATA (val);
-      if (v >= 0
+      if (0 <= v
          && (sizeof (off_t) < sizeof v
              ? v <= TYPE_MAXIMUM (off_t)
              : v < TYPE_MAXIMUM (off_t)))
index 82ce933b25de10abfea2e516e13504f7fac61b50..b3a1dc2317a47fa38d37f69ead108b34c42ffd86 100644 (file)
--- 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)
   ptrdiff_t n_max = (0 <= nitems_max && nitems_max < C_language_max
                     ? nitems_max : C_language_max);
   eassert (VECTORP (vec));
-  eassert (incr_min > 0 && nitems_max >= -1);
+  eassert (0 < incr_min && -1 <= nitems_max);
   old_size = ASIZE (vec);
   incr_max = n_max - old_size;
   incr = max (incr_min, min (old_size >> 1, incr_max));
@@ -3574,9 +3574,9 @@ make_hash_table (struct hash_table_test test,
   eassert (SYMBOLP (test.name));
   eassert (INTEGERP (size) && XINT (size) >= 0);
   eassert ((INTEGERP (rehash_size) && XINT (rehash_size) > 0)
-          || (FLOATP (rehash_size) && XFLOAT_DATA (rehash_size) > 1));
+          || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size)));
   eassert (FLOATP (rehash_threshold)
-          && XFLOAT_DATA (rehash_threshold) > 0
+          && 0 < XFLOAT_DATA (rehash_threshold)
           && XFLOAT_DATA (rehash_threshold) <= 1.0);
 
   if (XFASTINT (size) == 0)
@@ -4312,15 +4312,15 @@ usage: (make-hash-table &rest KEYWORD-ARGS)  */)
   /* Look for `:rehash-size SIZE'.  */
   i = get_key_arg (QCrehash_size, nargs, args, used);
   rehash_size = i ? args[i] : make_float (DEFAULT_REHASH_SIZE);
-  if (! ((INTEGERP (rehash_size) && XINT (rehash_size) > 0)
-        || (FLOATP (rehash_size) && XFLOAT_DATA (rehash_size) > 1)))
+  if (! ((INTEGERP (rehash_size) && 0 < XINT (rehash_size))
+        || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size))))
     signal_error ("Invalid hash table rehash size", rehash_size);
 
   /* Look for `:rehash-threshold THRESHOLD'.  */
   i = get_key_arg (QCrehash_threshold, nargs, args, used);
   rehash_threshold = i ? args[i] : make_float (DEFAULT_REHASH_THRESHOLD);
   if (! (FLOATP (rehash_threshold)
-        && XFLOAT_DATA (rehash_threshold) > 0
+        && 0 < XFLOAT_DATA (rehash_threshold)
         && XFLOAT_DATA (rehash_threshold) <= 1))
     signal_error ("Invalid hash table rehash threshold", rehash_threshold);
 
index d66620bffbcb4bce4db0560c250882cedfc4adbb..0b0144f3197525c2438ca67115bb45d586d158f6 100644 (file)
@@ -229,7 +229,7 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
 
   if (len == 1 && *str == '*')
     return Qnil;
-  if (!force_symbol && len > 0 && '0' <= *str && *str <= '9')
+  if (!force_symbol && 0 < len && '0' <= *str && *str <= '9')
     {
       for (i = 1; i < len; i++)
        if (! ('0' <= str[i] && str[i] <= '9'))
@@ -243,7 +243,7 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
            {
              if (i == len)
                return make_number (n);
-             if (n > MOST_POSITIVE_FIXNUM / 10)
+             if (MOST_POSITIVE_FIXNUM / 10 < n)
                break;
            }
 
index 970e40b517586ea7ca6afdfdad1b07554f004185..0aeaf4cf417b754759d1de1b83a8079d458fd28c 100644 (file)
@@ -889,7 +889,7 @@ DEFUN ("frame-list", Fframe_list, Sframe_list,
 /* Return CANDIDATE if it can be used as 'other-than-FRAME' frame on the
    same tty (for tty frames) or among frames which uses FRAME's keyboard.
    If MINIBUF is nil, do not consider minibuffer-only candidate.
-   If MINIBUF is `visible', do not consider an invisible candidate. 
+   If MINIBUF is `visible', do not consider an invisible candidate.
    If MINIBUF is a window, consider only its own frame and candidate now
    using that window as the minibuffer.
    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)
       else if (FLOATP (item))
        {
          alpha = XFLOAT_DATA (item);
-         if (alpha < 0.0 || alpha > 1.0)
+         if (! (0 <= alpha && alpha <= 1.0))
            args_out_of_range (make_float (0.0), make_float (1.0));
        }
       else if (INTEGERP (item))
        {
          EMACS_INT ialpha = XINT (item);
-         if (ialpha < 0 || ialpha > 100)
+         if (! (0 <= ialpha && alpha <= 100))
            args_out_of_range (make_number (0), make_number (100));
-         else
-           alpha = ialpha / 100.0;
+         alpha = ialpha / 100.0;
        }
       else
        wrong_type_argument (Qnumberp, item);
index 595a7427c21d3f5e7bba550e0d55578d2d40bff3..f83d8660fccf58fbe433f1d4567273a5ccdf9659 100644 (file)
@@ -543,7 +543,7 @@ get_utf8_string (const char *str)
       if (cp) g_free (cp);
 
       len = strlen (str);
-      if (nr_bad > (min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4)
+      if ((min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4 < nr_bad)
        memory_full (SIZE_MAX);
       up = utf8_str = xmalloc (len + nr_bad * 4 + 1);
       p = (unsigned char *)str;
index 345dfaa9ce3675c52ef7b8ccebe837965f765cdf..67796ab8a8fc1ee800342ad6bc69fd49b82fe76d 100644 (file)
@@ -466,7 +466,7 @@ check_display_width (ptrdiff_t pos, ptrdiff_t col, ptrdiff_t *endpos)
       if ((prop = Fplist_get (plist, QCwidth),
           RANGED_INTEGERP (0, prop, INT_MAX)))
        width = XINT (prop);
-      else if (FLOATP (prop) && XFLOAT_DATA (prop) >= 0
+      else if (FLOATP (prop) && 0 <= XFLOAT_DATA (prop)
               && XFLOAT_DATA (prop) <= INT_MAX)
        width = (int)(XFLOAT_DATA (prop) + 0.5);
       else if ((prop = Fplist_get (plist, QCalign_to),
index e759214fa336d6c99c7be5c85ed4be26ca1f787f..c43d528b25b4bb354f4a29ea4056a8f123add4b2 100644 (file)
@@ -2063,7 +2063,7 @@ For an approximate inverse of this, see `kbd'.  */)
     size += XINT (Flength (prefix));
 
   /* This has one extra element at the end that we don't pass to Fconcat.  */
-  if (size > min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4)
+  if (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size)
     memory_full (SIZE_MAX);
   SAFE_ALLOCA_LISP (args, size * 4);
 
index 4481a2e3373dd3746dc489f17aaab2364c3e6fd0..82cf0cb2678c31325a484f75bb4e1a3d780acfb5 100644 (file)
@@ -543,7 +543,7 @@ static EMACS_INT const VALMASK
    type or if I is a NaN.  */
 
 #define FIXNUM_OVERFLOW_P(i) \
-  (! (((i) >= 0 || (i) >= MOST_NEGATIVE_FIXNUM) && (i) <= MOST_POSITIVE_FIXNUM))
+  (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM))
 
 LISP_INLINE ptrdiff_t
 clip_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)
 LISP_INLINE void
 vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object *args, ptrdiff_t count)
 {
-  eassert (offset >= 0 && count >= 0 && offset + count <= ASIZE (v));
+  eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
   memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
 }
 
index d7a16f813c8f80717d7596a8b65394b9ba07594a..8e623e838c79f8602b0fa84f8fe0bb9c7afda5cf 100644 (file)
@@ -2636,7 +2636,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
            nskip--;
          else
            UNREAD (c);
-           
+
          if (load_force_doc_strings
              && (FROM_FILE_P (readcharfun)))
            {
@@ -2731,8 +2731,8 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
          /* Read a non-negative integer.  */
          while (c >= '0' && c <= '9')
            {
-             if (n > MOST_POSITIVE_FIXNUM / 10
-                 || n * 10 + c - '0' > MOST_POSITIVE_FIXNUM)
+             if (MOST_POSITIVE_FIXNUM / 10 < n
+                 || MOST_POSITIVE_FIXNUM < n * 10 + c - '0')
                n = MOST_POSITIVE_FIXNUM + 1;
              else
                n = n * 10 + c - '0';
@@ -2930,7 +2930,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
            if (end - p < MAX_MULTIBYTE_LENGTH)
              {
                ptrdiff_t offset = p - read_buffer;
-               if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2)
+               if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
                  memory_full (SIZE_MAX);
                read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
                read_buffer_size *= 2;
@@ -3064,7 +3064,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
              if (end - p < MAX_MULTIBYTE_LENGTH)
                {
                  ptrdiff_t offset = p - read_buffer;
-                 if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2)
+                 if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
                    memory_full (SIZE_MAX);
                  read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
                  read_buffer_size *= 2;
@@ -3094,7 +3094,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
          if (p == end)
            {
              ptrdiff_t offset = p - read_buffer;
-             if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2)
+             if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
                memory_full (SIZE_MAX);
              read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
              read_buffer_size *= 2;
index 75e547899129a28697230fb04af98351f4122f37..68c39310f01f7a7bbce3f2ed82f99af5d8d06cdc 100644 (file)
@@ -251,7 +251,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
        {
          if (len == size)
            {
-             if (size > STRING_BYTES_BOUND / 2)
+             if (STRING_BYTES_BOUND / 2 < size)
                memory_full (SIZE_MAX);
              size *= 2;
              line = xrealloc (line, size);
index 6a14a536707dc752d1d8e868f401640791faad6b..911a30bc808eaa6991c33d0d863977adda15bdd7 100644 (file)
@@ -4236,7 +4236,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
       time_limit = 0;
       nsecs = -1;
     }
-  else if (time_limit > TYPE_MAXIMUM (time_t))
+  else if (TYPE_MAXIMUM (time_t) < time_limit)
     time_limit = TYPE_MAXIMUM (time_t);
 
   /* Since we may need to wait several times,
index ece346ecd06ab886072add782540b0e7ba3ddb65..ea36133deb7e5ba65db97872ac2287442a54960e 100644 (file)
@@ -2533,9 +2533,9 @@ since only regular expressions have distinguished subexpressions.  */)
       bool str_multibyte = STRING_MULTIBYTE (newtext);
       bool really_changed = 0;
 
-      substed_alloc_size = (length > (STRING_BYTES_BOUND - 100) / 2
-                           ? STRING_BYTES_BOUND
-                           : length * 2 + 100);
+      substed_alloc_size = (length <= (STRING_BYTES_BOUND - 100) / 2
+                           ? length * 2 + 100
+                           : STRING_BYTES_BOUND);
       substed = xmalloc (substed_alloc_size);
       substed_len = 0;
 
index b66111a56057575daff553e2b91a00d6f65d225e..feb5f7b5cc7be8369bfc774a72b293b755dbd35c 100644 (file)
@@ -5944,7 +5944,7 @@ get_phys_cursor_glyph (struct window *w)
        hpos = row->used[TEXT_AREA] - 1;
     }
 
-  if (hpos >= 0 && hpos < row->used[TEXT_AREA])
+  if (0 <= hpos && hpos < row->used[TEXT_AREA])
     glyph = row->glyphs[TEXT_AREA] + hpos;
   else
     glyph = NULL;
index a7be5fc275cd82e0a4677870122bb90cdcc1a05d..41214880a562434237c57aa84d99850dc67e6ebe 100644 (file)
@@ -13168,7 +13168,7 @@ redisplay_internal (void)
               PT == w->last_point
               /* Make sure the cursor was last displayed
                  in this window.  Otherwise we have to reposition it.  */
-              && w->cursor.vpos >= 0
+              && 0 <= w->cursor.vpos
               && w->cursor.vpos < WINDOW_TOTAL_LINES (w))
        {
          if (!must_finish)
index 0af196d21606d4f973c10eddfe2007c3aa50e68c..cb7122202df7f71a56e2f6130ffb9bb719209999 100644 (file)
@@ -221,7 +221,7 @@ smc_save_yourself_CB (SmcConn smcConn,
   props[props_idx]->name = xstrdup (SmRestartCommand);
   props[props_idx]->type = xstrdup (SmLISTofARRAY8);
   /* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */
-  if (initial_argc > INT_MAX - 3)
+  if (INT_MAX - 3 < initial_argc)
     memory_full (SIZE_MAX);
   i = 3 + initial_argc;
   props[props_idx]->num_vals = i;