From: Andreas Schwab <schwab@linux-m68k.org>
Date: Sat, 26 Jul 2014 11:58:24 +0000 (+0200)
Subject: Reorder conditions that are written backwards
X-Git-Tag: emacs-25.0.90~2636^3~40
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=3acf58eec890249179b6f992c59f9adcf05b8ca8;p=emacs.git

Reorder conditions that are written backwards

* alloc.c (xnmalloc, xnrealloc, xpalloc, make_save_value)
(Fgarbage_collect): Reorder conditions that are written backwards.
* data.c (cons_to_unsigned): Likewise.
* dispnew.c (update_frame_1, sit_for): Likewise.
* fileio.c (file_offset): Likewise.
* filelock.c (read_lock_data, lock_file): Likewise.
* fns.c (larger_vector, make_hash_table, Fmake_hash_table):
Likewise.
* font.c (font_intern_prop, font_style_symbolic): Likewise.
* lisp.h (FIXNUM_OVERFLOW_P): Likewise.
* lread.c (read1): Likewise.
* minibuf.c (read_minibuf_noninteractive): Likewise.
* nsterm.m (x_set_frame_alpha): Likewise.
* process.c (wait_reading_process_output): Likewise.
* region-cache.c (delete_cache_boundaries): Likewise.
* xterm.c (x_set_frame_alpha): Likewise.
---

diff --git a/src/alloc.c b/src/alloc.c
index a8ad44491fa..f5f25d53435 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -806,8 +806,8 @@ verify (INT_MAX <= PTRDIFF_MAX);
 void *
 xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size)
 {
-  eassert (0 <= nitems && 0 < item_size);
-  if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems)
+  eassert (nitems >= 0 && item_size > 0);
+  if (nitems > min (PTRDIFF_MAX, SIZE_MAX) / item_size)
     memory_full (SIZE_MAX);
   return xmalloc (nitems * item_size);
 }
@@ -819,8 +819,8 @@ xnmalloc (ptrdiff_t nitems, ptrdiff_t item_size)
 void *
 xnrealloc (void *pa, ptrdiff_t nitems, ptrdiff_t item_size)
 {
-  eassert (0 <= nitems && 0 < item_size);
-  if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems)
+  eassert (nitems >= 0 && item_size > 0);
+  if (nitems > min (PTRDIFF_MAX, SIZE_MAX) / item_size)
     memory_full (SIZE_MAX);
   return xrealloc (pa, nitems * item_size);
 }
@@ -873,10 +873,10 @@ 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 (0 < item_size && 0 < nitems_incr_min && 0 <= n && -1 <= nitems_max);
+  eassert (item_size > 0 && nitems_incr_min > 0 && n >= 0 && nitems_max >= -1);
   if (! pa)
     *nitems = 0;
-  if (nitems_incr_max < incr)
+  if (incr > nitems_incr_max)
     memory_full (SIZE_MAX);
   n += incr;
   pa = xrealloc (pa, n * item_size);
@@ -1183,7 +1183,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
 	}
       ABLOCKS_BUSY (abase) = (struct ablocks *) aligned;
 
-      eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN);
+      eassert ((uintptr_t) abase % BLOCK_ALIGN == 0);
       eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */
       eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase);
       eassert (ABLOCKS_BASE (abase) == base);
@@ -1205,7 +1205,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
 
   MALLOC_PROBE (nbytes);
 
-  eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN);
+  eassert ((uintptr_t) val % BLOCK_ALIGN == 0);
   return val;
 }
 
@@ -5706,7 +5706,7 @@ garbage_collect_1 (void *end)
       double tot = total_bytes_of_live_objects ();
 
       tot *= XFLOAT_DATA (Vgc_cons_percentage);
-      if (0 < tot)
+      if (tot > 0)
 	{
 	  if (tot < TYPE_MAXIMUM (EMACS_INT))
 	    gc_relative_threshold = tot;
diff --git a/src/data.c b/src/data.c
index 3e651414e68..cb0e9a825fb 100644
--- a/src/data.c
+++ b/src/data.c
@@ -2460,13 +2460,13 @@ cons_to_unsigned (Lisp_Object c, uintmax_t max)
   uintmax_t val IF_LINT (= 0);
   if (INTEGERP (c))
     {
-      valid = 0 <= XINT (c);
+      valid = XINT (c) >= 0;
       val = XINT (c);
     }
   else if (FLOATP (c))
     {
       double d = XFLOAT_DATA (c);
-      if (0 <= d
+      if (d >= 0
 	  && d < (max == UINTMAX_MAX ? (double) UINTMAX_MAX + 1 : max + 1))
 	{
 	  val = d;
diff --git a/src/dispnew.c b/src/dispnew.c
index 2d137b4abbd..045ad2ed70b 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5829,7 +5829,7 @@ sit_for (Lisp_Object timeout, bool reading, int display_option)
   else if (FLOATP (timeout))
     {
       double seconds = XFLOAT_DATA (timeout);
-      if (! (0 < seconds))
+      if (! (seconds > 0))
 	return Qt;
       else
 	{
diff --git a/src/fileio.c b/src/fileio.c
index f0bd75b170e..9829e4d9813 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -3367,8 +3367,8 @@ file_offset (Lisp_Object val)
   if (FLOATP (val))
     {
       double v = XFLOAT_DATA (val);
-      if (0 <= v
-	  && (sizeof (off_t) < sizeof v
+      if (v >= 0
+	  && (sizeof v > sizeof (off_t)
 	      ? v <= TYPE_MAXIMUM (off_t)
 	      : v < TYPE_MAXIMUM (off_t)))
 	return v;
diff --git a/src/filelock.c b/src/filelock.c
index f857c488143..bbc616206d7 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -504,7 +504,7 @@ read_lock_data (char *lfname, char lfinfo[MAX_LFINFO + 1])
 	 && errno == EINVAL)
     {
       int fd = emacs_open (lfname, O_RDONLY | O_BINARY | O_NOFOLLOW, 0);
-      if (0 <= fd)
+      if (fd >= 0)
 	{
 	  /* Use read, not emacs_read, since FD isn't unwind-protected.  */
 	  ptrdiff_t read_bytes = read (fd, lfinfo, MAX_LFINFO + 1);
@@ -713,7 +713,7 @@ lock_file (Lisp_Object fn)
   }
 
   /* Try to lock the lock.  */
-  if (0 < lock_if_free (&lock_info, lfname))
+  if (lock_if_free (&lock_info, lfname) > 0)
     {
       /* Someone else has the lock.  Consider breaking it.  */
       Lisp_Object attack;
diff --git a/src/fns.c b/src/fns.c
index 79967116a11..68bfadf5022 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3496,7 +3496,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 (0 < incr_min && -1 <= nitems_max);
+  eassert (incr_min > 0 && nitems_max >= -1);
   old_size = ASIZE (vec);
   incr_max = n_max - old_size;
   incr = max (incr_min, min (old_size >> 1, incr_max));
@@ -3659,9 +3659,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) && 1 < XFLOAT_DATA (rehash_size)));
+	   || (FLOATP (rehash_size) && XFLOAT_DATA (rehash_size) > 1));
   eassert (FLOATP (rehash_threshold)
-	   && 0 < XFLOAT_DATA (rehash_threshold)
+	   && XFLOAT_DATA (rehash_threshold) > 0
 	   && XFLOAT_DATA (rehash_threshold) <= 1.0);
 
   if (XFASTINT (size) == 0)
@@ -4399,15 +4399,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) && 0 < XINT (rehash_size))
-	 || (FLOATP (rehash_size) && 1 < XFLOAT_DATA (rehash_size))))
+  if (! ((INTEGERP (rehash_size) && XINT (rehash_size) > 0)
+	 || (FLOATP (rehash_size) && XFLOAT_DATA (rehash_size) > 1)))
     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)
-	 && 0 < XFLOAT_DATA (rehash_threshold)
+	 && XFLOAT_DATA (rehash_threshold) > 0
 	 && XFLOAT_DATA (rehash_threshold) <= 1))
     signal_error ("Invalid hash table rehash threshold", rehash_threshold);
 
diff --git a/src/font.c b/src/font.c
index 054a68bfd94..ee6d230e171 100644
--- a/src/font.c
+++ b/src/font.c
@@ -280,7 +280,7 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol)
 
   if (len == 1 && *str == '*')
     return Qnil;
-  if (!force_symbol && 0 < len && '0' <= *str && *str <= '9')
+  if (!force_symbol && len > 0 && '0' <= *str && *str <= '9')
     {
       for (i = 1; i < len; i++)
 	if (! ('0' <= str[i] && str[i] <= '9'))
@@ -445,10 +445,10 @@ font_style_symbolic (Lisp_Object font, enum font_property_index prop,
   table = AREF (font_style_table, prop - FONT_WEIGHT_INDEX);
   CHECK_VECTOR (table);
   i = XINT (val) & 0xFF;
-  eassert (((i >> 4) & 0xF) < ASIZE (table));
+  eassert (ASIZE (table) > ((i >> 4) & 0xF));
   elt = AREF (table, ((i >> 4) & 0xF));
   CHECK_VECTOR (elt);
-  eassert ((i & 0xF) + 1 < ASIZE (elt));
+  eassert (ASIZE (elt) > (i & 0xF) + 1);
   elt = (for_face ? AREF (elt, 1) : AREF (elt, (i & 0xF) + 1));
   CHECK_SYMBOL (elt);
   return elt;
diff --git a/src/lisp.h b/src/lisp.h
index bf25f073d4b..623becc4b33 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -782,7 +782,7 @@ LISP_MACRO_DEFUN (EQ, bool, (Lisp_Object x, Lisp_Object y), (x, y))
    type or if I is a NaN.  */
 
 #define FIXNUM_OVERFLOW_P(i) \
-  (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM))
+  (! (((i) >= 0 || (i) >= MOST_NEGATIVE_FIXNUM) && (i) <= MOST_POSITIVE_FIXNUM))
 
 INLINE ptrdiff_t
 clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper)
diff --git a/src/lread.c b/src/lread.c
index 639d574ac6b..25c3503d86b 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -2747,7 +2747,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	  while ((c = READCHAR) >= 0
 		 && c >= '0' && c <= '9')
 	    {
-	      if ((STRING_BYTES_BOUND - extra) / 10 <= nskip)
+	      if (nskip >= (STRING_BYTES_BOUND - extra) / 10)
 		string_overflow ();
 	      digits++;
 	      nskip *= 10;
@@ -2861,8 +2861,8 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	  /* Read a non-negative integer.  */
 	  while (c >= '0' && c <= '9')
 	    {
-	      if (MOST_POSITIVE_FIXNUM / 10 < n
-		  || MOST_POSITIVE_FIXNUM < n * 10 + c - '0')
+	      if (n > MOST_POSITIVE_FIXNUM / 10
+		  || n * 10 + c - '0' > MOST_POSITIVE_FIXNUM)
 		n = MOST_POSITIVE_FIXNUM + 1;
 	      else
 		n = n * 10 + c - '0';
@@ -3058,7 +3058,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	    if (end - p < MAX_MULTIBYTE_LENGTH)
 	      {
 		ptrdiff_t offset = p - read_buffer;
-		if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
+		if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2)
 		  memory_full (SIZE_MAX);
 		read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
 		read_buffer_size *= 2;
@@ -3192,7 +3192,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	      if (end - p < MAX_MULTIBYTE_LENGTH)
 		{
 		  ptrdiff_t offset = p - read_buffer;
-		  if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
+		  if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2)
 		    memory_full (SIZE_MAX);
 		  read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
 		  read_buffer_size *= 2;
@@ -3222,7 +3222,7 @@ read1 (Lisp_Object readcharfun, int *pch, bool first_in_list)
 	  if (p == end)
 	    {
 	      ptrdiff_t offset = p - read_buffer;
-	      if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
+	      if (read_buffer_size > min (PTRDIFF_MAX, SIZE_MAX) / 2)
 		memory_full (SIZE_MAX);
 	      read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
 	      read_buffer_size *= 2;
diff --git a/src/minibuf.c b/src/minibuf.c
index b85d3f57df3..e4f81906873 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -265,7 +265,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial,
 	    fprintf (stdout, "%c", hide_char);
 	  if (len == size)
 	    {
-	      if (STRING_BYTES_BOUND / 2 < size)
+	      if (size > STRING_BYTES_BOUND / 2)
 		memory_full (SIZE_MAX);
 	      size *= 2;
 	      line = xrealloc (line, size);
diff --git a/src/nsterm.m b/src/nsterm.m
index 3b1c945c6bf..762c4e79ea8 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -1795,9 +1795,9 @@ x_set_frame_alpha (struct frame *f)
 
   if (alpha < 0.0)
     return;
-  else if (1.0 < alpha)
+  else if (alpha > 1.0)
     alpha = 1.0;
-  else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
+  else if (alpha >= 0.0 && alpha < alpha_min && alpha_min <= 1.0)
     alpha = alpha_min;
 
 #ifdef NS_IMPL_COCOA
diff --git a/src/process.c b/src/process.c
index 4449493a2b6..ab30698b9e8 100644
--- a/src/process.c
+++ b/src/process.c
@@ -4303,7 +4303,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
       time_limit = 0;
       nsecs = -1;
     }
-  else if (TYPE_MAXIMUM (time_t) < time_limit)
+  else if (time_limit > TYPE_MAXIMUM (time_t))
     time_limit = TYPE_MAXIMUM (time_t);
 
   /* Since we may need to wait several times,
@@ -4580,7 +4580,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
 			continue;
 		      FD_CLR (channel, &Available);
 		      XPROCESS (proc)->read_output_skip = 0;
-		      if (XPROCESS (proc)->read_output_delay < nsecs)
+		      if (nsecs > XPROCESS (proc)->read_output_delay)
 			nsecs = XPROCESS (proc)->read_output_delay;
 		    }
 		}
@@ -4696,7 +4696,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
 	  if (timers_run != old_timers_run
 	      && waiting_for_user_input_p == -1
 	      && (old_buffer != current_buffer
-	      || !EQ (old_window, selected_window)))
+		  || !EQ (old_window, selected_window)))
 	    record_asynch_buffer_change ();
 
 	  if (leave)
diff --git a/src/region-cache.c b/src/region-cache.c
index 1123a0fb755..2bd091fe4e1 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -315,7 +315,7 @@ delete_cache_boundaries (struct region_cache *c,
   ptrdiff_t len = end - start;
 
   /* Gotta be in range.  */
-  eassert (0 <= start && end <= c->cache_len);
+  eassert (start >= 0 && end <= c->cache_len);
 
   /* Gotta be in order.  */
   eassert (start <= end);
diff --git a/src/xterm.c b/src/xterm.c
index 85835a2c7c5..df2a9f331ef 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -394,7 +394,7 @@ x_set_frame_alpha (struct frame *f)
     return;
   else if (alpha > 1.0)
     alpha = 1.0;
-  else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0)
+  else if (alpha >= 0.0 && alpha < alpha_min && alpha_min <= 1.0)
     alpha = alpha_min;
 
   opac = alpha * OPAQUE;