From: Andreas Schwab Date: Sun, 24 Mar 2013 12:59:45 +0000 (+0100) Subject: Reorder conditions that are written backwards X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~526^2~101 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=908589fd28437a9b0995b103e22ce5e4d421eb8a;p=emacs.git Reorder conditions that are written backwards * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are written backwards. * blockinput.h (input_blocked_p): Likewise. * bytecode.c (exec_byte_code): Likewise. * callproc.c (call_process_kill, call_process_cleanup) (Fcall_process): Likewise. * ccl.c (ccl_driver, resolve_symbol_ccl_program) (Fccl_execute_on_string): Likewise. * character.c (string_escape_byte8): Likewise. * charset.c (read_hex): Likewise. * cm.c (calccost): Likewise. * data.c (cons_to_unsigned): Likewise. * dired.c (directory_files_internal, file_name_completion): Likewise. * dispnew.c (scrolling_window, update_frame_1, Fsleep_for) (sit_for): Likewise. * doc.c (Fsubstitute_command_keys): Likewise. * doprnt.c (doprnt): Likewise. * editfns.c (hi_time, decode_time_components, Fformat): Likewise. * emacsgtkfixed.c: Likewise. * fileio.c (file_offset, Fwrite_region): Likewise. * floatfns.c (Fexpt, fmod_float): Likewise. * fns.c (larger_vector, make_hash_table, Fmake_hash_table): Likewise. * font.c (font_intern_prop): Likewise. * frame.c (x_set_alpha): Likewise. * gtkutil.c (get_utf8_string): Likewise. * indent.c (check_display_width): Likewise. * intervals.c (create_root_interval, rotate_right, rotate_left) (split_interval_right, split_interval_left) (adjust_intervals_for_insertion, delete_node) (interval_deletion_adjustment, adjust_intervals_for_deletion) (merge_interval_right, merge_interval_left, copy_intervals) (set_intervals_multibyte_1): Likewise. * keyboard.c (gobble_input, append_tool_bar_item): Likewise. * keymap.c (Fkey_description): Likewise. * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise. * lread.c (openp, read_integer, read1, string_to_number): Likewise. * menu.c (ensure_menu_items): Likewise. * minibuf.c (read_minibuf_noninteractive): Likewise. * print.c (printchar, strout): Likewise. * process.c (create_process, Faccept_process_output) (wait_reading_process_output, read_process_output, send_process) (wait_reading_process_output): Likewise. * profiler.c (make_log, handle_profiler_signal): Likewise. * regex.c (re_exec): Likewise. * regex.h: Likewise. * search.c (looking_at_1, Freplace_match): Likewise. * sysdep.c (get_child_status, procfs_ttyname) (procfs_get_total_memory): Likewise. * systime.h (EMACS_TIME_VALID_P): Likewise. * term.c (dissociate_if_controlling_tty): Likewise. * window.c (get_phys_cursor_glyph): Likewise. * xdisp.c (init_iterator, redisplay_internal, redisplay_window) (try_window_reusing_current_matrix, try_window_id, pint2hrstr): Likewise. * xfns.c (Fx_window_property): Likewise. * xmenu.c (set_frame_menubar): Likewise. * xselect.c (x_get_window_property, x_handle_dnd_message): Likewise. * xsmfns.c (smc_save_yourself_CB): Likewise. * xterm.c (x_scroll_bar_set_handle): Likewise. --- diff --git a/src/ChangeLog b/src/ChangeLog index fb1c4fdc64c..1875147dc64 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,69 @@ +2013-03-24 Andreas Schwab + + * alloc.c (xpalloc, Fgarbage_collect): Reorder conditions that are + written backwards. + * blockinput.h (input_blocked_p): Likewise. + * bytecode.c (exec_byte_code): Likewise. + * callproc.c (call_process_kill, call_process_cleanup) + (Fcall_process): Likewise. + * ccl.c (ccl_driver, resolve_symbol_ccl_program) + (Fccl_execute_on_string): Likewise. + * character.c (string_escape_byte8): Likewise. + * charset.c (read_hex): Likewise. + * cm.c (calccost): Likewise. + * data.c (cons_to_unsigned): Likewise. + * dired.c (directory_files_internal, file_name_completion): + Likewise. + * dispnew.c (scrolling_window, update_frame_1, Fsleep_for) + (sit_for): Likewise. + * doc.c (Fsubstitute_command_keys): Likewise. + * doprnt.c (doprnt): Likewise. + * editfns.c (hi_time, decode_time_components, Fformat): Likewise. + * emacsgtkfixed.c: Likewise. + * fileio.c (file_offset, Fwrite_region): Likewise. + * floatfns.c (Fexpt, fmod_float): Likewise. + * fns.c (larger_vector, make_hash_table, Fmake_hash_table): + Likewise. + * font.c (font_intern_prop): Likewise. + * frame.c (x_set_alpha): Likewise. + * gtkutil.c (get_utf8_string): Likewise. + * indent.c (check_display_width): Likewise. + * intervals.c (create_root_interval, rotate_right, rotate_left) + (split_interval_right, split_interval_left) + (adjust_intervals_for_insertion, delete_node) + (interval_deletion_adjustment, adjust_intervals_for_deletion) + (merge_interval_right, merge_interval_left, copy_intervals) + (set_intervals_multibyte_1): Likewise. + * keyboard.c (gobble_input, append_tool_bar_item): Likewise. + * keymap.c (Fkey_description): Likewise. + * lisp.h (FIXNUM_OVERFLOW_P, vcopy): Likewise. + * lread.c (openp, read_integer, read1, string_to_number): + Likewise. + * menu.c (ensure_menu_items): Likewise. + * minibuf.c (read_minibuf_noninteractive): Likewise. + * print.c (printchar, strout): Likewise. + * process.c (create_process, Faccept_process_output) + (wait_reading_process_output, read_process_output, send_process) + (wait_reading_process_output): Likewise. + * profiler.c (make_log, handle_profiler_signal): Likewise. + * regex.c (re_exec): Likewise. + * regex.h: Likewise. + * search.c (looking_at_1, Freplace_match): Likewise. + * sysdep.c (get_child_status, procfs_ttyname) + (procfs_get_total_memory): Likewise. + * systime.h (EMACS_TIME_VALID_P): Likewise. + * term.c (dissociate_if_controlling_tty): Likewise. + * window.c (get_phys_cursor_glyph): Likewise. + * xdisp.c (init_iterator, redisplay_internal, redisplay_window) + (try_window_reusing_current_matrix, try_window_id, pint2hrstr): + Likewise. + * xfns.c (Fx_window_property): Likewise. + * xmenu.c (set_frame_menubar): Likewise. + * xselect.c (x_get_window_property, x_handle_dnd_message): + Likewise. + * xsmfns.c (smc_save_yourself_CB): Likewise. + * xterm.c (x_scroll_bar_set_handle): Likewise. + 2013-03-24 Dmitry Antipov * xfaces.c (Finternal_face_x_get_resource): Allow 3rd (frame) argument @@ -5273,8 +5339,8 @@ a public macro and no need to inline by hand. 2012-09-26 Tomohiro Matsuyama - Stefan Monnier - Juanma Barranquero + Stefan Monnier + Juanma Barranquero * profiler.c: New file. * Makefile.in (base_obj): Add profiler.o. diff --git a/src/alloc.c b/src/alloc.c index 4245b3069fa..ea833c62b94 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -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 (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) @@ -5376,7 +5376,7 @@ See Info node `(elisp)Garbage Collection'. */) 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/blockinput.h b/src/blockinput.h index 192c813073d..6dc22c6f5dd 100644 --- a/src/blockinput.h +++ b/src/blockinput.h @@ -67,7 +67,7 @@ extern void unblock_input_to (int); BLOCKINPUT_INLINE bool input_blocked_p (void) { - return 0 < interrupt_input_blocked; + return interrupt_input_blocked > 0; } INLINE_HEADER_END diff --git a/src/bytecode.c b/src/bytecode.c index acb96c1e61b..7676c8550a4 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -660,7 +660,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, the table clearer. */ #define LABEL(OP) [OP] = &&insn_ ## OP -#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Woverride-init" #endif @@ -676,7 +676,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, #undef DEFINE }; -#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic pop #endif diff --git a/src/callproc.c b/src/callproc.c index 9132c0dd976..46a37701a40 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1,5 +1,5 @@ /* Synchronous subprocess invocation for GNU Emacs. - Copyright (C) 1985-1988, 1993-1995, 1999-2012 + Copyright (C) 1985-1988, 1993-1995, 1999-2013 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -125,7 +125,7 @@ record_kill_process (struct Lisp_Process *p) static Lisp_Object call_process_kill (Lisp_Object ignored) { - if (0 <= synch_process_fd) + if (synch_process_fd >= 0) emacs_close (synch_process_fd); if (synch_process_pid) @@ -173,7 +173,7 @@ call_process_cleanup (Lisp_Object arg) } #endif - if (0 <= synch_process_fd) + if (synch_process_fd >= 0) emacs_close (synch_process_fd); #ifdef MSDOS @@ -682,7 +682,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) child_errno = errno; - if (0 < pid) + if (pid > 0) { if (INTEGERP (buffer)) record_deleted_pid (pid); diff --git a/src/ccl.c b/src/ccl.c index 7f77e1d22fa..c3b3f5486c4 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 } map = XCDR (map); if (! (VECTORP (map) - && 0 < ASIZE (map) + && ASIZE (map) > 0 && 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 (! (0 <= XINT (AREF (result, CCL_HEADER_BUF_MAG)) + if (! (XINT (AREF (result, CCL_HEADER_BUF_MAG)) >= 0 && ASCENDING_ORDER (0, XINT (AREF (result, CCL_HEADER_EOF)), ASIZE (ccl)))) return Qnil; @@ -2130,7 +2130,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY produced_chars += ccl.produced; offset = outp - outbuf; shortfall = ccl.produced * max_expansion - (outbufsize - offset); - if (0 < shortfall) + if (shortfall > 0) { outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1); outp = outbuf + offset; diff --git a/src/character.c b/src/character.c index b2caaa290af..5a06c7f4d6c 100644 --- a/src/character.c +++ b/src/character.c @@ -833,8 +833,8 @@ string_escape_byte8 (Lisp_Object string) if (multibyte) { - if ((MOST_POSITIVE_FIXNUM - nchars) / 3 < byte8_count - || (STRING_BYTES_BOUND - nbytes) / 2 < byte8_count) + if (byte8_count > (MOST_POSITIVE_FIXNUM - nchars) / 3 + || byte8_count > (STRING_BYTES_BOUND - nbytes) / 2) 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 ((STRING_BYTES_BOUND - nbytes) / 3 < byte8_count) + if (byte8_count > (STRING_BYTES_BOUND - nbytes) / 3) string_overflow (); /* Convert 1-byte sequence of byte8 chars to 4-byte octal. */ diff --git a/src/charset.c b/src/charset.c index fdb8eebde8b..3d43d81877f 100644 --- a/src/charset.c +++ b/src/charset.c @@ -447,7 +447,7 @@ read_hex (FILE *fp, bool *eof, bool *overflow) n = 0; while (c_isxdigit (c = getc (fp))) { - if (UINT_MAX >> 4 < n) + if (n > UINT_MAX >> 4) *overflow = 1; n = ((n << 4) | (c - ('0' <= c && c <= '9' ? '0' diff --git a/src/cm.c b/src/cm.c index 3a5f927eda3..481ac15e435 100644 --- a/src/cm.c +++ b/src/cm.c @@ -214,7 +214,7 @@ calccost (struct tty_display_info *tty, if (doit) do emacs_tputs (tty, p, 1, cmputc); - while (0 < --deltay); + while (--deltay > 0); x: if ((deltax = dstx - srcx) == 0) goto done; @@ -297,7 +297,7 @@ fail: if (doit) do emacs_tputs (tty, p, 1, cmputc); - while (0 < --deltax); + while (--deltax > 0); done: return totalcost; } diff --git a/src/data.c b/src/data.c index 6622088b648..b20d1b4c8af 100644 --- a/src/data.c +++ b/src/data.c @@ -2337,13 +2337,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/dired.c b/src/dired.c index 0e37568f211..ab48488966b 100644 --- a/src/dired.c +++ b/src/dired.c @@ -258,7 +258,7 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full, QUIT; if (NILP (match) - || (0 <= re_search (bufp, SSDATA (name), len, 0, len, 0))) + || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0) wanted = 1; immediate_quit = 0; @@ -517,8 +517,8 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, QUIT; if (len < SCHARS (encoded_file) - || 0 <= scmp (dp->d_name, SSDATA (encoded_file), - SCHARS (encoded_file))) + || scmp (dp->d_name, SSDATA (encoded_file), + SCHARS (encoded_file)) >= 0) continue; if (file_name_completion_stat (fd, dp, &st) < 0) @@ -580,7 +580,7 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, if (skip < 0) continue; - if (0 <= scmp (dp->d_name + skip, p1, elt_len)) + if (scmp (dp->d_name + skip, p1, elt_len) >= 0) continue; break; } @@ -602,9 +602,8 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag, skip = len - SCHARS (elt); if (skip < 0) continue; - if (0 <= scmp (dp->d_name + skip, - SSDATA (elt), - SCHARS (elt))) + if (scmp (dp->d_name + skip, SSDATA (elt), SCHARS (elt)) + >= 0) continue; break; } diff --git a/src/dispnew.c b/src/dispnew.c index 41d4844707e..852598d2dc8 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -4459,7 +4459,7 @@ scrolling_window (struct window *w, bool header_line_p) row_table[row_entry_pool[i].bucket] = NULL; /* Value is 1 to indicate that we scrolled the display. */ - return 0 < nruns; + return nruns > 0; } @@ -4545,7 +4545,7 @@ update_frame_1 (struct frame *f, bool force_p, bool inhibit_id_p) } } - lint_assume (0 <= FRAME_LINES (f)); + lint_assume (FRAME_LINES (f) >= 0); pause_p = 0 < i && i < FRAME_LINES (f) - 1; /* Now just clean up termcap drivers and set cursor, etc. */ @@ -5764,7 +5764,7 @@ additional wait period, in milliseconds; this is for backwards compatibility. duration += XINT (milliseconds) / 1000.0; } - if (0 < duration) + if (duration > 0) { EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (duration); wait_reading_process_output (min (EMACS_SECS (t), WAIT_READING_MAX), @@ -5804,14 +5804,14 @@ sit_for (Lisp_Object timeout, bool reading, int display_option) if (INTEGERP (timeout)) { sec = XINT (timeout); - if (! (0 < sec)) + if (sec <= 0) return Qt; nsec = 0; } else if (FLOATP (timeout)) { double seconds = XFLOAT_DATA (timeout); - if (! (0 < seconds)) + if (seconds <= 0) return Qt; else { diff --git a/src/doc.c b/src/doc.c index 7234fb38bf9..1ddaa117bba 100644 --- 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 (STRING_BYTES_BOUND - 4 < bsize) + if (bsize > STRING_BYTES_BOUND - 4) string_overflow (); buf = xrealloc (buf, bsize += 4); bufp = buf + offset; diff --git a/src/doprnt.c b/src/doprnt.c index 471e35c7b43..087256ced2a 100644 --- a/src/doprnt.c +++ b/src/doprnt.c @@ -361,7 +361,7 @@ doprnt (char *buffer, ptrdiff_t bufsize, const char *format, /* Copy string into final output, truncating if no room. */ doit: - eassert (0 <= tem); + eassert (tem >= 0); /* Coming here means STRING contains ASCII only. */ if (STRING_BYTES_BOUND < tem) error ("Format width or precision too large"); diff --git a/src/editfns.c b/src/editfns.c index 6357a28e8ea..2d87b8e0064 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -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) - || MOST_NEGATIVE_FIXNUM <= TIME_T_MIN >> 16 - || MOST_NEGATIVE_FIXNUM <= hi) + || TIME_T_MIN >> 16 >= MOST_NEGATIVE_FIXNUM + || hi >= MOST_NEGATIVE_FIXNUM) && (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 ((TYPE_SIGNED (time_t) ? TIME_T_MIN >> 16 <= hi : 0 <= hi) + if (hi >= (TYPE_SIGNED (time_t) ? TIME_T_MIN >> 16 : 0) && hi <= TIME_T_MAX >> 16) { /* Return the greatest representable time that is not greater @@ -3958,7 +3958,7 @@ usage: (format STRING &rest OBJECTS) */) trailing "d"). */ pMlen = sizeof pMd - 2 }; - verify (0 < USEFUL_PRECISION_MAX); + verify (USEFUL_PRECISION_MAX > 0); int prec; ptrdiff_t padding, sprintf_bytes; diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c index 6a8c751e306..970683da9c4 100644 --- a/src/emacsgtkfixed.c +++ b/src/emacsgtkfixed.c @@ -28,7 +28,7 @@ along with GNU Emacs. If not, see . */ #include "xterm.h" /* Silence a bogus diagnostic; see GNOME bug 683906. */ -#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-local-typedefs" #endif diff --git a/src/fileio.c b/src/fileio.c index 3d7bd9fe216..1919768d98a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -3449,7 +3449,7 @@ file_offset (Lisp_Object val) if (FLOATP (val)) { double v = XFLOAT_DATA (val); - if (0 <= v + if (v >= 0 && (sizeof (off_t) < sizeof v ? v <= TYPE_MAXIMUM (off_t) : v < TYPE_MAXIMUM (off_t))) @@ -5013,7 +5013,7 @@ This calls `write-region-annotate-functions' at the start, and && ! (valid_timestamp_file_system && st.st_dev == timestamp_file_system)) { int desc1 = emacs_open (fn, O_WRONLY | O_BINARY, 0); - if (0 <= desc1) + if (desc1 >= 0) { struct stat st1; if (fstat (desc1, &st1) == 0 diff --git a/src/floatfns.c b/src/floatfns.c index 43576a16248..6113758f964 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -193,7 +193,7 @@ DEFUN ("expt", Fexpt, Sexpt, 2, 2, 0, CHECK_NUMBER_OR_FLOAT (arg2); if (INTEGERP (arg1) /* common lisp spec */ && INTEGERP (arg2) /* don't promote, if both are ints, and */ - && 0 <= XINT (arg2)) /* we are sure the result is not fractional */ + && XINT (arg2) >= 0) /* we are sure the result is not fractional */ { /* this can be improved by pre-calculating */ EMACS_INT y; /* some binary powers of x then accumulating */ EMACS_UINT acc, x; /* Unsigned so that overflow is well defined. */ @@ -475,7 +475,7 @@ fmod_float (Lisp_Object x, Lisp_Object y) f1 = fmod (f1, f2); /* If the "remainder" comes out with the wrong sign, fix it. */ - if (f2 < 0 ? 0 < f1 : f1 < 0) + if (f2 < 0 ? f1 > 0 : f1 < 0) f1 += f2; return make_float (f1); diff --git a/src/fns.c b/src/fns.c index b3a1dc2317a..82ce933b25d 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) 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)); @@ -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) && 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) @@ -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) && 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 ba98d19afa0..357f8483b14 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) 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')) @@ -243,7 +243,7 @@ font_intern_prop (const char *str, ptrdiff_t len, bool force_symbol) { if (i == len) return make_number (n); - if (MOST_POSITIVE_FIXNUM / 10 < n) + if (n > MOST_POSITIVE_FIXNUM / 10) break; } diff --git a/src/frame.c b/src/frame.c index 5360c1c701d..cea39144cef 100644 --- a/src/frame.c +++ b/src/frame.c @@ -3315,13 +3315,13 @@ x_set_alpha (struct frame *f, Lisp_Object arg, Lisp_Object oldval) else if (FLOATP (item)) { alpha = XFLOAT_DATA (item); - if (alpha < 0.0 || 1.0 < alpha) + if (alpha < 0.0 || 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 || 100 < ialpha) + if (ialpha < 0 || ialpha > 100) args_out_of_range (make_number (0), make_number (100)); else alpha = ialpha / 100.0; diff --git a/src/gtkutil.c b/src/gtkutil.c index d6e4dcebcd3..2bb4305e1d2 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -543,7 +543,7 @@ get_utf8_string (const char *str) if (cp) g_free (cp); len = strlen (str); - if ((min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4 < nr_bad) + if (nr_bad > (min (PTRDIFF_MAX, SIZE_MAX) - len - 1) / 4) memory_full (SIZE_MAX); up = utf8_str = xmalloc (len + nr_bad * 4 + 1); p = (unsigned char *)str; diff --git a/src/indent.c b/src/indent.c index d1f95da6bcf..ac448532dd4 100644 --- a/src/indent.c +++ b/src/indent.c @@ -476,7 +476,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) && 0 <= XFLOAT_DATA (prop) + else if (FLOATP (prop) && XFLOAT_DATA (prop) >= 0 && XFLOAT_DATA (prop) <= INT_MAX) width = (int)(XFLOAT_DATA (prop) + 0.5); else if ((prop = Fplist_get (plist, QCalign_to), diff --git a/src/intervals.c b/src/intervals.c index db38c86c00b..f65ce0ecc77 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -110,14 +110,14 @@ create_root_interval (Lisp_Object parent) { new->total_length = (BUF_Z (XBUFFER (parent)) - BUF_BEG (XBUFFER (parent))); - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); set_buffer_intervals (XBUFFER (parent), new); new->position = BEG; } else if (STRINGP (parent)) { new->total_length = SCHARS (parent); - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); set_string_intervals (parent, new); new->position = 0; } @@ -371,11 +371,11 @@ rotate_right (INTERVAL interval) /* A's total length is decreased by the length of B and its left child. */ interval->total_length -= B->total_length - LEFT_TOTAL_LENGTH (interval); - eassert (0 <= TOTAL_LENGTH (interval)); + eassert (TOTAL_LENGTH (interval) >= 0); /* B must have the same total length of A. */ B->total_length = old_total; - eassert (0 <= TOTAL_LENGTH (B)); + eassert (TOTAL_LENGTH (B) >= 0); return B; } @@ -418,11 +418,11 @@ rotate_left (INTERVAL interval) /* A's total length is decreased by the length of B and its right child. */ interval->total_length -= B->total_length - RIGHT_TOTAL_LENGTH (interval); - eassert (0 <= TOTAL_LENGTH (interval)); + eassert (TOTAL_LENGTH (interval) >= 0); /* B must have the same total length of A. */ B->total_length = old_total; - eassert (0 <= TOTAL_LENGTH (B)); + eassert (TOTAL_LENGTH (B) >= 0); return B; } @@ -556,7 +556,7 @@ split_interval_right (INTERVAL interval, ptrdiff_t offset) { set_interval_right (interval, new); new->total_length = new_length; - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); } else { @@ -565,7 +565,7 @@ split_interval_right (INTERVAL interval, ptrdiff_t offset) set_interval_parent (interval->right, new); set_interval_right (interval, new); new->total_length = new_length + new->right->total_length; - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); balance_an_interval (new); } @@ -601,7 +601,7 @@ split_interval_left (INTERVAL interval, ptrdiff_t offset) { set_interval_left (interval, new); new->total_length = new_length; - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); } else { @@ -610,7 +610,7 @@ split_interval_left (INTERVAL interval, ptrdiff_t offset) set_interval_parent (new->left, new); set_interval_left (interval, new); new->total_length = new_length + new->left->total_length; - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); balance_an_interval (new); } @@ -960,7 +960,7 @@ adjust_intervals_for_insertion (INTERVAL tree, for (temp = prev ? prev : i; temp; temp = INTERVAL_PARENT_OR_NULL (temp)) { temp->total_length += length; - eassert (0 <= TOTAL_LENGTH (temp)); + eassert (TOTAL_LENGTH (temp) >= 0); temp = balance_possible_root_interval (temp); } @@ -1016,7 +1016,7 @@ adjust_intervals_for_insertion (INTERVAL tree, for (temp = i; temp; temp = INTERVAL_PARENT_OR_NULL (temp)) { temp->total_length += length; - eassert (0 <= TOTAL_LENGTH (temp)); + eassert (TOTAL_LENGTH (temp) >= 0); temp = balance_possible_root_interval (temp); } } @@ -1218,7 +1218,7 @@ delete_node (register INTERVAL i) this = this->left; this->total_length += migrate_amt; } - eassert (0 <= TOTAL_LENGTH (this)); + eassert (TOTAL_LENGTH (this) >= 0); set_interval_left (this, migrate); set_interval_parent (migrate, this); @@ -1300,7 +1300,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from, relative_position, amount); tree->total_length -= subtract; - eassert (0 <= TOTAL_LENGTH (tree)); + eassert (TOTAL_LENGTH (tree) >= 0); return subtract; } /* Right branch. */ @@ -1315,7 +1315,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from, relative_position, amount); tree->total_length -= subtract; - eassert (0 <= TOTAL_LENGTH (tree)); + eassert (TOTAL_LENGTH (tree) >= 0); return subtract; } /* Here -- this node. */ @@ -1330,7 +1330,7 @@ interval_deletion_adjustment (register INTERVAL tree, register ptrdiff_t from, amount = my_amount; tree->total_length -= amount; - eassert (0 <= TOTAL_LENGTH (tree)); + eassert (TOTAL_LENGTH (tree) >= 0); if (LENGTH (tree) == 0) delete_interval (tree); @@ -1372,7 +1372,7 @@ adjust_intervals_for_deletion (struct buffer *buffer, if (ONLY_INTERVAL_P (tree)) { tree->total_length -= length; - eassert (0 <= TOTAL_LENGTH (tree)); + eassert (TOTAL_LENGTH (tree) >= 0); return; } @@ -1435,19 +1435,19 @@ merge_interval_right (register INTERVAL i) while (! NULL_LEFT_CHILD (successor)) { successor->total_length += absorb; - eassert (0 <= TOTAL_LENGTH (successor)); + eassert (TOTAL_LENGTH (successor) >= 0); successor = successor->left; } successor->total_length += absorb; - eassert (0 <= TOTAL_LENGTH (successor)); + eassert (TOTAL_LENGTH (successor) >= 0); delete_interval (i); return successor; } /* Zero out this interval. */ i->total_length -= absorb; - eassert (0 <= TOTAL_LENGTH (i)); + eassert (TOTAL_LENGTH (i) >= 0); successor = i; while (! NULL_PARENT (successor)) /* It's above us. Subtract as @@ -1462,7 +1462,7 @@ merge_interval_right (register INTERVAL i) successor = INTERVAL_PARENT (successor); successor->total_length -= absorb; - eassert (0 <= TOTAL_LENGTH (successor)); + eassert (TOTAL_LENGTH (successor) >= 0); } /* This must be the rightmost or last interval and cannot @@ -1491,19 +1491,19 @@ merge_interval_left (register INTERVAL i) while (! NULL_RIGHT_CHILD (predecessor)) { predecessor->total_length += absorb; - eassert (0 <= TOTAL_LENGTH (predecessor)); + eassert (TOTAL_LENGTH (predecessor) >= 0); predecessor = predecessor->right; } predecessor->total_length += absorb; - eassert (0 <= TOTAL_LENGTH (predecessor)); + eassert (TOTAL_LENGTH (predecessor) >= 0); delete_interval (i); return predecessor; } /* Zero out this interval. */ i->total_length -= absorb; - eassert (0 <= TOTAL_LENGTH (i)); + eassert (TOTAL_LENGTH (i) >= 0); predecessor = i; while (! NULL_PARENT (predecessor)) /* It's above us. Go up, @@ -1518,7 +1518,7 @@ merge_interval_left (register INTERVAL i) predecessor = INTERVAL_PARENT (predecessor); predecessor->total_length -= absorb; - eassert (0 <= TOTAL_LENGTH (predecessor)); + eassert (TOTAL_LENGTH (predecessor) >= 0); } /* This must be the leftmost or first interval and cannot @@ -2272,7 +2272,7 @@ copy_intervals (INTERVAL tree, ptrdiff_t start, ptrdiff_t length) new->position = 0; got = (LENGTH (i) - (start - i->position)); new->total_length = length; - eassert (0 <= TOTAL_LENGTH (new)); + eassert (TOTAL_LENGTH (new) >= 0); copy_properties (i, new); t = new; @@ -2355,7 +2355,7 @@ set_intervals_multibyte_1 (INTERVAL i, bool multi_flag, i->total_length = end - start; else i->total_length = end_byte - start_byte; - eassert (0 <= TOTAL_LENGTH (i)); + eassert (TOTAL_LENGTH (i) >= 0); if (TOTAL_LENGTH (i) == 0) { diff --git a/src/keyboard.c b/src/keyboard.c index e43b7a73172..d9187cd96b4 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6766,7 +6766,7 @@ gobble_input (void) hold_quit.kind = NO_EVENT; /* No need for FIONREAD or fcntl; just say don't wait. */ - while (0 < (nr = (*t->read_socket_hook) (t, &hold_quit))) + while ((nr = (*t->read_socket_hook) (t, &hold_quit)) > 0) nread += nr; if (nr == -1) /* Not OK to read input now. */ @@ -8240,9 +8240,8 @@ append_tool_bar_item (void) - (ASIZE (tool_bar_items_vector) - TOOL_BAR_ITEM_NSLOTS)); /* Enlarge tool_bar_items_vector if necessary. */ - if (0 < incr) - tool_bar_items_vector - = larger_vector (tool_bar_items_vector, incr, -1); + if (incr > 0) + tool_bar_items_vector = larger_vector (tool_bar_items_vector, incr, -1); /* Append entries from tool_bar_item_properties to the end of tool_bar_items_vector. */ diff --git a/src/keymap.c b/src/keymap.c index 34406a5fc70..110c8f43729 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -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 (min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4 < size) + if (size > min (PTRDIFF_MAX, SIZE_MAX) / word_size / 4) memory_full (SIZE_MAX); SAFE_ALLOCA_LISP (args, size * 4); diff --git a/src/lisp.h b/src/lisp.h index 467710f52f4..897addc90c1 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -543,7 +543,7 @@ static EMACS_INT const VALMASK 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)) LISP_INLINE ptrdiff_t clip_to_bounds (ptrdiff_t lower, EMACS_INT num, ptrdiff_t upper) @@ -2565,7 +2565,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 (0 <= offset && 0 <= count && offset + count <= ASIZE (v)); + eassert (offset >= 0 && count >= 0 && offset + count <= ASIZE (v)); memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args); } diff --git a/src/lread.c b/src/lread.c index f8ab03af218..d7a16f813c8 100644 --- a/src/lread.c +++ b/src/lread.c @@ -1571,7 +1571,7 @@ openp (Lisp_Object path, Lisp_Object str, Lisp_Object suffixes, Lisp_Object *sto { struct stat st; fd = emacs_open (pfn, O_RDONLY, 0); - if (0 <= fd + if (fd >= 0 && (fstat (fd, &st) != 0 || S_ISDIR (st.st_mode))) { emacs_close (fd); @@ -2359,7 +2359,7 @@ read_integer (Lisp_Object readcharfun, EMACS_INT radix) while (c == '0'); } - while (-1 <= (digit = digit_to_number (c, radix))) + while ((digit = digit_to_number (c, radix)) >= -1) { if (digit == -1) valid = 0; @@ -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 (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'; @@ -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 (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; @@ -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 (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; @@ -3094,7 +3094,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; @@ -3298,12 +3298,12 @@ string_to_number (char const *string, int base, bool ignore_trailing) state = 0; leading_digit = digit_to_number (*cp, base); - if (0 <= leading_digit) + if (leading_digit >= 0) { state |= LEAD_INT; do ++cp; - while (0 <= digit_to_number (*cp, base)); + while (digit_to_number (*cp, base) >= 0); } if (*cp == '.') { @@ -3380,7 +3380,7 @@ string_to_number (char const *string, int base, bool ignore_trailing) /* If the number uses integer and not float syntax, and is in C-language range, use its value, preferably as a fixnum. */ - if (0 <= leading_digit && ! float_syntax) + if (leading_digit >= 0 && ! float_syntax) { uintmax_t n; diff --git a/src/menu.c b/src/menu.c index fdef54dd657..ffb5c3bc936 100644 --- a/src/menu.c +++ b/src/menu.c @@ -173,7 +173,7 @@ static void ensure_menu_items (int items) { int incr = items - (menu_items_allocated - menu_items_used); - if (0 < incr) + if (incr > 0) { menu_items = larger_vector (menu_items, incr, INT_MAX); menu_items_allocated = ASIZE (menu_items); diff --git a/src/minibuf.c b/src/minibuf.c index 25425cb97dc..56459353714 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -251,7 +251,7 @@ read_minibuf_noninteractive (Lisp_Object map, Lisp_Object initial, { 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/print.c b/src/print.c index 4ab80fe1605..ce10d6295e6 100644 --- a/src/print.c +++ b/src/print.c @@ -227,9 +227,9 @@ printchar (unsigned int ch, Lisp_Object fun) if (NILP (fun)) { ptrdiff_t incr = len - (print_buffer_size - print_buffer_pos_byte); - if (0 < incr) - print_buffer = - xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); + if (incr > 0) + print_buffer = xpalloc (print_buffer, &print_buffer_size, + incr, -1, 1); memcpy (print_buffer + print_buffer_pos_byte, str, len); print_buffer_pos += 1; print_buffer_pos_byte += len; @@ -273,7 +273,7 @@ strout (const char *ptr, ptrdiff_t size, ptrdiff_t size_byte, if (NILP (printcharfun)) { ptrdiff_t incr = size_byte - (print_buffer_size - print_buffer_pos_byte); - if (0 < incr) + if (incr > 0) print_buffer = xpalloc (print_buffer, &print_buffer_size, incr, -1, 1); memcpy (print_buffer + print_buffer_pos_byte, ptr, size_byte); print_buffer_pos += size; diff --git a/src/process.c b/src/process.c index ed71ff76e6a..6a14a536707 100644 --- a/src/process.c +++ b/src/process.c @@ -136,7 +136,7 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *, /* Work around GCC 4.7.0 bug with strict overflow checking; see . These lines can be removed once the GCC bug is fixed. */ -#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) # pragma GCC diagnostic ignored "-Wstrict-overflow" #endif @@ -1804,7 +1804,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) /* Back in the parent process. */ XPROCESS (process)->pid = pid; - if (0 <= pid) + if (pid >= 0) XPROCESS (process)->alive = 1; /* Stop blocking signals in the parent. */ @@ -3901,7 +3901,7 @@ Return non-nil if we received any output before the timeout expired. */) { if (INTEGERP (seconds)) { - if (0 < XINT (seconds)) + if (XINT (seconds) > 0) { secs = XINT (seconds); nsecs = 0; @@ -3909,7 +3909,7 @@ Return non-nil if we received any output before the timeout expired. */) } else if (FLOATP (seconds)) { - if (0 < XFLOAT_DATA (seconds)) + if (XFLOAT_DATA (seconds) > 0) { EMACS_TIME t = EMACS_TIME_FROM_DOUBLE (XFLOAT_DATA (seconds)); secs = min (EMACS_SECS (t), WAIT_READING_MAX); @@ -4236,12 +4236,12 @@ 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, compute the absolute time to return at. */ - if (time_limit || 0 < nsecs) + if (time_limit || nsecs > 0) { timeout = make_emacs_time (time_limit, nsecs); end_time = add_emacs_time (current_emacs_time (), timeout); @@ -4273,7 +4273,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, timeout = make_emacs_time (0, 0); } - else if (time_limit || 0 < nsecs) + else if (time_limit || nsecs > 0) { EMACS_TIME now = current_emacs_time (); if (EMACS_TIME_LE (end_time, now)) @@ -4325,7 +4325,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, break; /* A negative timeout means do not wait at all. */ - if (0 <= nsecs) + if (nsecs >= 0) { if (EMACS_TIME_VALID_P (timer_delay)) { @@ -4407,7 +4407,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (nread == 0) break; - if (0 < nread) + if (nread > 0) { total_nread += nread; got_some_input = 1; @@ -4948,7 +4948,7 @@ read_process_output (Lisp_Object proc, register int channel) else #endif { - bool buffered = 0 <= proc_buffered_char[channel]; + bool buffered = proc_buffered_char[channel] >= 0; if (buffered) { chars[carryover] = proc_buffered_char[channel]; @@ -5455,7 +5455,7 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len, rv = sendto (outfd, cur_buf, cur_len, 0, datagram_address[outfd].sa, datagram_address[outfd].len); - if (0 <= rv) + if (rv >= 0) written = rv; else if (errno == EMSGSIZE) report_file_error ("sending datagram", Fcons (proc, Qnil)); @@ -6578,7 +6578,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, time_limit = TYPE_MAXIMUM (time_t); /* What does time_limit really mean? */ - if (time_limit || 0 < nsecs) + if (time_limit || nsecs > 0) { timeout = make_emacs_time (time_limit, nsecs); end_time = add_emacs_time (current_emacs_time (), timeout); @@ -6616,7 +6616,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, timeout = make_emacs_time (0, 0); } - else if (time_limit || 0 < nsecs) + else if (time_limit || nsecs > 0) { EMACS_TIME now = current_emacs_time (); if (EMACS_TIME_LE (end_time, now)) @@ -6654,7 +6654,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, && requeued_events_pending_p ()) break; - if (EMACS_TIME_VALID_P (timer_delay) && 0 <= nsecs) + if (EMACS_TIME_VALID_P (timer_delay) && nsecs >= 0) { if (EMACS_TIME_LT (timer_delay, timeout)) { diff --git a/src/profiler.c b/src/profiler.c index 85d9c1ca88a..0a0a4d0bc57 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -55,7 +55,7 @@ make_log (int heap_size, int max_stack_depth) /* What is special about our hash-tables is that the keys are pre-filled with the vectors we'll put in them. */ int i = ASIZE (h->key_and_value) / 2; - while (0 < i) + while (i > 0) set_hash_key_slot (h, --i, Fmake_vector (make_number (max_stack_depth), Qnil)); return log; @@ -247,7 +247,7 @@ handle_profiler_signal (int signal) if (profiler_timer_ok) { int overruns = timer_getoverrun (profiler_timer); - eassert (0 <= overruns); + eassert (overruns >= 0); count += overruns; } #endif diff --git a/src/regex.c b/src/regex.c index 051a4fdc26b..648f2529649 100644 --- a/src/regex.c +++ b/src/regex.c @@ -33,7 +33,7 @@ /* Ignore some GCC warnings for now. This section should go away once the Emacs and Gnulib regex code is merged. */ -#if (__GNUC__ == 4 && 5 <= __GNUC_MINOR__) || 4 < __GNUC__ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) # pragma GCC diagnostic ignored "-Wstrict-overflow" # ifndef emacs # pragma GCC diagnostic ignored "-Wunused-but-set-variable" @@ -6404,8 +6404,8 @@ weak_function re_exec (const char *s) { const size_t len = strlen (s); - return - 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0); + return (re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0) + >= 0); } #endif /* _REGEX_RE_COMP */ diff --git a/src/regex.h b/src/regex.h index f1fd837bd6f..8fe7ba16adc 100644 --- a/src/regex.h +++ b/src/regex.h @@ -530,7 +530,7 @@ extern int re_exec (const char *); /* GCC 2.95 and later have "__restrict"; C99 compilers have "restrict", and "configure" may have defined "restrict". */ #ifndef __restrict -# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) +# if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) # if defined restrict || 199901L <= __STDC_VERSION__ # define __restrict restrict # else diff --git a/src/search.c b/src/search.c index c5ac7d494dc..ece346ecd06 100644 --- a/src/search.c +++ b/src/search.c @@ -326,7 +326,7 @@ looking_at_1 (Lisp_Object string, bool posix) if (i == -2) matcher_overflow (); - val = (0 <= i ? Qt : Qnil); + val = (i >= 0 ? Qt : Qnil); if (NILP (Vinhibit_changing_match_data) && i >= 0) for (i = 0; i < search_regs.num_regs; i++) if (search_regs.start[i] >= 0) @@ -2450,7 +2450,7 @@ since only regular expressions have distinguished subexpressions. */) else if (c >= '1' && c <= '9') { if (c - '0' < search_regs.num_regs - && 0 <= search_regs.start[c - '0']) + && search_regs.start[c - '0'] >= 0) { substart = search_regs.start[c - '0']; subend = search_regs.end[c - '0']; @@ -2533,7 +2533,7 @@ since only regular expressions have distinguished subexpressions. */) bool str_multibyte = STRING_MULTIBYTE (newtext); bool really_changed = 0; - substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length + substed_alloc_size = (length > (STRING_BYTES_BOUND - 100) / 2 ? STRING_BYTES_BOUND : length * 2 + 100); substed = xmalloc (substed_alloc_size); diff --git a/src/sysdep.c b/src/sysdep.c index bff11fc9f75..1d3e646d359 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -282,7 +282,7 @@ get_child_status (pid_t child, int *status, int options, bool interruptible) reap an unwanted process by mistake. For example, invoking waitpid (-1, ...) can mess up glib by reaping glib's subprocesses, so that another thread running glib won't find them. */ - eassert (0 < child); + eassert (child > 0); while ((pid = waitpid (child, status, options)) < 0) { @@ -2691,7 +2691,7 @@ procfs_ttyname (int rdev) while (!feof (fdev) && !ferror (fdev)) { - if (3 <= fscanf (fdev, "%*s %s %u %s %*s\n", name, &major, minor) + if (fscanf (fdev, "%*s %s %u %s %*s\n", name, &major, minor) >= 3 && major == MAJOR (rdev)) { minor_beg = strtoul (minor, &endp, 0); @@ -2731,7 +2731,7 @@ procfs_get_total_memory (void) while (!feof (fmem) && !ferror (fmem)) { - if (2 <= fscanf (fmem, "%s %lu kB\n", entry_name, &entry_value) + if (fscanf (fmem, "%s %lu kB\n", entry_name, &entry_value) >= 2 && strcmp (entry_name, "MemTotal:") == 0) { retval = entry_value; diff --git a/src/systime.h b/src/systime.h index fa5e7270cb5..da495b9064b 100644 --- a/src/systime.h +++ b/src/systime.h @@ -121,7 +121,7 @@ EMACS_TIME_SIGN (EMACS_TIME t) SYSTIME_INLINE int EMACS_TIME_VALID_P (EMACS_TIME t) { - return 0 <= t.tv_nsec; + return t.tv_nsec >= 0; } /* Convert the double D to the greatest EMACS_TIME not greater than D. diff --git a/src/term.c b/src/term.c index 38706602a02..28b944c6436 100644 --- a/src/term.c +++ b/src/term.c @@ -2909,7 +2909,7 @@ dissociate_if_controlling_tty (int fd) { /* If tcgetpgrp succeeds, fd is the controlling terminal, so dissociate it by invoking setsid. */ - if (0 <= tcgetpgrp (fd) && setsid () < 0) + if (tcgetpgrp (fd) >= 0 && setsid () < 0) { #ifdef TIOCNOTTY /* setsid failed, presumably because Emacs is already a process diff --git a/src/window.c b/src/window.c index 875d7770277..1784b38ba6d 100644 --- a/src/window.c +++ b/src/window.c @@ -6002,8 +6002,7 @@ get_phys_cursor_glyph (struct window *w) hpos = row->used[TEXT_AREA] - 1; } - if (row->used[TEXT_AREA] > hpos - && 0 <= hpos) + if (hpos >= 0 && hpos < row->used[TEXT_AREA]) glyph = row->glyphs[TEXT_AREA] + hpos; else glyph = NULL; diff --git a/src/xdisp.c b/src/xdisp.c index 25b143d362a..d42e53fc314 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2677,7 +2677,7 @@ init_iterator (struct it *it, struct window *w, and IT->region_end_charpos to the start and end of a visible region in window IT->w. Set both to -1 to indicate no region. */ markpos = markpos_of_region (); - if (0 <= markpos + if (markpos >= 0 /* Maybe highlight only in selected window. */ && (/* Either show region everywhere. */ highlight_nonselected_windows @@ -13170,8 +13170,8 @@ redisplay_internal (void) PT == w->last_point /* Make sure the cursor was last displayed in this window. Otherwise we have to reposition it. */ - && 0 <= w->cursor.vpos - && WINDOW_TOTAL_LINES (w) > w->cursor.vpos) + && w->cursor.vpos >= 0 + && w->cursor.vpos < WINDOW_TOTAL_LINES (w)) { if (!must_finish) { @@ -15520,7 +15520,7 @@ redisplay_window (Lisp_Object window, int just_this_one_p) /* If we are highlighting the region, then we just changed the region, so redisplay to show it. */ - if (0 <= markpos_of_region ()) + if (markpos_of_region () >= 0) { clear_glyph_matrix (w->desired_matrix); if (!try_window (window, startp, 0)) @@ -16221,7 +16221,7 @@ try_window_reusing_current_matrix (struct window *w) return 0; /* Can't do this if region may have changed. */ - if (0 <= markpos_of_region () + if (markpos_of_region () >= 0 || w->region_showing || !NILP (Vshow_trailing_whitespace)) return 0; @@ -17053,7 +17053,7 @@ try_window_id (struct window *w) /* Can't use this if highlighting a region because a cursor movement will do more than just set the cursor. */ - if (0 <= markpos_of_region ()) + if (markpos_of_region () >= 0) GIVE_UP (9); /* Likewise if highlighting trailing whitespace. */ @@ -21008,7 +21008,7 @@ pint2hrstr (char *buf, int width, ptrdiff_t d) char * psuffix; char * p; - if (1000 <= quotient) + if (quotient >= 1000) { /* Scale to the appropriate EXPONENT. */ do @@ -21017,13 +21017,13 @@ pint2hrstr (char *buf, int width, ptrdiff_t d) quotient /= 1000; exponent++; } - while (1000 <= quotient); + while (quotient >= 1000); /* Round to nearest and decide whether to use TENTHS or not. */ if (quotient <= 9) { tenths = remainder / 100; - if (50 <= remainder % 100) + if (remainder % 100 >= 50) { if (tenths < 9) tenths++; @@ -21038,7 +21038,7 @@ pint2hrstr (char *buf, int width, ptrdiff_t d) } } else - if (500 <= remainder) + if (remainder >= 500) { if (quotient < 999) quotient++; diff --git a/src/xfns.c b/src/xfns.c index 488365561d3..a6a179be97d 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -4322,7 +4322,7 @@ no value of TYPE (always string in the MS Windows case). */) property and those are indeed in 32 bit quantities if format is 32. */ - if (32 < BITS_PER_LONG && actual_format == 32) + if (BITS_PER_LONG > 32 && actual_format == 32) { unsigned long i; int *idata = (int *) tmp_data; diff --git a/src/xmenu.c b/src/xmenu.c index 57cf27f955d..af08eeb657c 100644 --- a/src/xmenu.c +++ b/src/xmenu.c @@ -1055,7 +1055,7 @@ set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p) wv->help = Qnil; first_wv = wv; - for (i = 0; 0 <= submenu_start[i]; i++) + for (i = 0; submenu_start[i] >= 0; i++) { menu_items_n_panes = submenu_n_panes[i]; wv = digest_single_submenu (submenu_start[i], submenu_end[i], diff --git a/src/xselect.c b/src/xselect.c index e9a8e2107db..cca1a47212b 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1388,7 +1388,7 @@ x_get_window_property (Display *display, Window window, Atom property, data = data1; } - if (32 < BITS_PER_LONG && *actual_format_ret == 32) + if (BITS_PER_LONG > 32 && *actual_format_ret == 32) { unsigned long i; int *idata = (int *) (data + offset); @@ -2541,7 +2541,7 @@ x_handle_dnd_message (struct frame *f, XClientMessageEvent *event, function expects them to be of size int (i.e. 32). So to be able to use that function, put the data in the form it expects if format is 32. */ - if (32 < BITS_PER_LONG && event->format == 32) + if (BITS_PER_LONG > 32 && event->format == 32) { for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ idata[i] = event->data.l[i]; diff --git a/src/xsmfns.c b/src/xsmfns.c index cb7122202df..0af196d2160 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -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 (INT_MAX - 3 < initial_argc) + if (initial_argc > INT_MAX - 3) memory_full (SIZE_MAX); i = 3 + initial_argc; props[props_idx]->num_vals = i; diff --git a/src/xterm.c b/src/xterm.c index 88433b6c0b3..d8c2dfdda82 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -5076,7 +5076,7 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, int rebuild /* Draw the empty space above the handle. Note that we can't clear zero-height areas; that means "clear to end of window." */ - if (0 < start) + if (start > 0) x_clear_area (FRAME_X_DISPLAY (f), w, /* x, y, width, height, and exposures. */ VERTICAL_SCROLL_BAR_LEFT_BORDER,