From: Paul Eggert Date: Sat, 26 Jul 2014 13:17:25 +0000 (-0700) Subject: Revert previous change. X-Git-Tag: emacs-25.0.90~2636^3~37 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9e9f8582a893f1e97b1f8955f69b96f969ee1f85;p=emacs.git Revert previous change. There is certainly nothing wrong with writing code like 'lo <= i && i <= hi', even if LO happens to a constant. There isn't even anything wrong in general with writing 'a <= b' if A happens to be a constant. At any rate stylistic changes shouldn't be done like this without discussion. --- diff --git a/src/ChangeLog b/src/ChangeLog index fee5842c6b6..6843cfac089 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2014-07-26 Paul Eggert + + Revert previous change. + There is certainly nothing wrong with writing code like 'lo <= i + && i <= hi', even if LO happens to a constant. There isn't even + anything wrong in general with writing 'a <= b' if A happens to + be a constant. At any rate stylistic changes shouldn't + be done like this without discussion. + 2014-07-26 Andreas Schwab * alloc.c (xnmalloc, xnrealloc, xpalloc, make_save_value) diff --git a/src/alloc.c b/src/alloc.c index f5f25d53435..a8ad44491fa 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 (nitems >= 0 && item_size > 0); - if (nitems > min (PTRDIFF_MAX, SIZE_MAX) / item_size) + eassert (0 <= nitems && 0 < item_size); + if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems) 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 (nitems >= 0 && item_size > 0); - if (nitems > min (PTRDIFF_MAX, SIZE_MAX) / item_size) + eassert (0 <= nitems && 0 < item_size); + if (min (PTRDIFF_MAX, SIZE_MAX) / item_size < nitems) 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 (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 (incr > nitems_incr_max) + if (nitems_incr_max < incr) 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 ((uintptr_t) abase % BLOCK_ALIGN == 0); + eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN); 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 ((uintptr_t) val % BLOCK_ALIGN == 0); + eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN); 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 (tot > 0) + if (0 < tot) { if (tot < TYPE_MAXIMUM (EMACS_INT)) gc_relative_threshold = tot; diff --git a/src/data.c b/src/data.c index cb0e9a825fb..3e651414e68 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 = 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; diff --git a/src/dispnew.c b/src/dispnew.c index 045ad2ed70b..2d137b4abbd 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 (! (seconds > 0)) + if (! (0 < seconds)) return Qt; else { diff --git a/src/fileio.c b/src/fileio.c index 9829e4d9813..f0bd75b170e 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 (v >= 0 - && (sizeof v > sizeof (off_t) + if (0 <= v + && (sizeof (off_t) < sizeof v ? v <= TYPE_MAXIMUM (off_t) : v < TYPE_MAXIMUM (off_t))) return v; diff --git a/src/filelock.c b/src/filelock.c index bbc616206d7..f857c488143 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 (fd >= 0) + if (0 <= fd) { /* 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 (lock_if_free (&lock_info, lfname) > 0) + if (0 < lock_if_free (&lock_info, lfname)) { /* Someone else has the lock. Consider breaking it. */ Lisp_Object attack; diff --git a/src/fns.c b/src/fns.c index 68bfadf5022..79967116a11 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 (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)); @@ -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) && 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) @@ -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) && 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); diff --git a/src/font.c b/src/font.c index ee6d230e171..054a68bfd94 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 && 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')) @@ -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 (ASIZE (table) > ((i >> 4) & 0xF)); + eassert (((i >> 4) & 0xF) < ASIZE (table)); elt = AREF (table, ((i >> 4) & 0xF)); CHECK_VECTOR (elt); - eassert (ASIZE (elt) > (i & 0xF) + 1); + eassert ((i & 0xF) + 1 < ASIZE (elt)); 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 623becc4b33..bf25f073d4b 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) \ - (! (((i) >= 0 || (i) >= MOST_NEGATIVE_FIXNUM) && (i) <= MOST_POSITIVE_FIXNUM)) + (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (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 25c3503d86b..639d574ac6b 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 (nskip >= (STRING_BYTES_BOUND - extra) / 10) + if ((STRING_BYTES_BOUND - extra) / 10 <= nskip) 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 (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'; @@ -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 (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; @@ -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 (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; @@ -3222,7 +3222,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; diff --git a/src/minibuf.c b/src/minibuf.c index e4f81906873..b85d3f57df3 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 (size > STRING_BYTES_BOUND / 2) + if (STRING_BYTES_BOUND / 2 < size) memory_full (SIZE_MAX); size *= 2; line = xrealloc (line, size); diff --git a/src/nsterm.m b/src/nsterm.m index 762c4e79ea8..3b1c945c6bf 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 (alpha > 1.0) + else if (1.0 < alpha) alpha = 1.0; - else if (alpha >= 0.0 && alpha < alpha_min && alpha_min <= 1.0) + else if (0.0 <= alpha && 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 ab30698b9e8..4449493a2b6 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 (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, @@ -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 (nsecs > XPROCESS (proc)->read_output_delay) + if (XPROCESS (proc)->read_output_delay < nsecs) 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 2bd091fe4e1..1123a0fb755 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 (start >= 0 && end <= c->cache_len); + eassert (0 <= start && end <= c->cache_len); /* Gotta be in order. */ eassert (start <= end); diff --git a/src/xterm.c b/src/xterm.c index df2a9f331ef..85835a2c7c5 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 (alpha >= 0.0 && alpha < alpha_min && alpha_min <= 1.0) + else if (0.0 <= alpha && alpha < alpha_min && alpha_min <= 1.0) alpha = alpha_min; opac = alpha * OPAQUE;