+2014-07-26 Paul Eggert <eggert@cs.ucla.edu>
+
+ 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 <schwab@linux-m68k.org>
* alloc.c (xnmalloc, xnrealloc, xpalloc, make_save_value)
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);
}
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);
}
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);
}
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);
MALLOC_PROBE (nbytes);
- eassert ((uintptr_t) val % BLOCK_ALIGN == 0);
+ eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN);
return val;
}
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;
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;
else if (FLOATP (timeout))
{
double seconds = XFLOAT_DATA (timeout);
- if (! (seconds > 0))
+ if (! (0 < seconds))
return Qt;
else
{
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;
&& 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);
}
/* 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;
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));
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)
/* 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);
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'))
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;
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)
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;
/* 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';
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;
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;
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;
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);
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
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,
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;
}
}
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)
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);
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;