From a9ebfa0b3eb23056f523742e53ce79279cae1bd0 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 23 Mar 2013 19:40:51 -0700 Subject: Static checking by GCC 4.8-20130319. * image.c (gif_load): Assume pass < 3 to pacify GCC. * process.c (Fset_process_datagram_address) (Fmake_network_process): Check get_lisp_to_sockaddr_size return value. * xdisp.c (get_char_face_and_encoding): (get_glyph_face_and_encoding): Ensure that *CHAR2B is initialized. (get_glyph_face_and_encoding): Prepare face before possibly using it. (get_per_char_metric): Don't use CHAR2B if it might not be initialized. --- src/process.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/process.c') diff --git a/src/process.c b/src/process.c index bafdca9bd63..ed71ff76e6a 100644 --- a/src/process.c +++ b/src/process.c @@ -2155,7 +2155,7 @@ Returns nil upon error setting address, ADDRESS otherwise. */) channel = XPROCESS (process)->infd; len = get_lisp_to_sockaddr_size (address, &family); - if (datagram_address[channel].len != len) + if (len == 0 || datagram_address[channel].len != len) return Qnil; conv_lisp_to_sockaddr (family, address, datagram_address[channel].sa, len); return address; @@ -3269,7 +3269,8 @@ usage: (make-network-process &rest ARGS) */) { int rfamily, rlen; rlen = get_lisp_to_sockaddr_size (remote, &rfamily); - if (rfamily == lres->ai_family && rlen == lres->ai_addrlen) + if (rlen != 0 && rfamily == lres->ai_family + && rlen == lres->ai_addrlen) conv_lisp_to_sockaddr (rfamily, remote, datagram_address[s].sa, rlen); } -- cgit v1.2.1 From 908589fd28437a9b0995b103e22ce5e4d421eb8a Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 24 Mar 2013 13:59:45 +0100 Subject: 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. --- src/process.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/process.c') 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)) { -- cgit v1.2.1