From d9df6f40e326f3f5487b7c50b99bf5112262badc Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Mar 2013 00:27:34 -0700 Subject: [PATCH] Static checking by Sun C 5.12. * lib-src/etags.c (analyse_regex): Omit unreachable code. * src/alloc.c (buffer_memory_full) [REL_ALLOC]: * src/bytecode.c (exec_byte_code): * src/dispnew.c (init_display): * src/eval.c (error): * src/fileio.c (Fsubstitute_in_file_name): * src/keyboard.c (Fevent_convert_list): * src/keymap.c (Fsingle_key_description): * src/term.c (maybe_fatal, fatal): * src/xfns.c (Fx_display_backing_store, Fx_display_visual_class): * src/xsmfns.c (Fhandle_save_session): Omit unreachable code. * src/keymap.c (map_keymap_char_table_item): Cast void * to a function pointer type; the C Standard requires this. --- lib-src/ChangeLog | 3 +++ lib-src/etags.c | 5 +---- src/ChangeLog | 15 +++++++++++++++ src/alloc.c | 4 ++-- src/bytecode.c | 2 -- src/dispnew.c | 5 +---- src/eval.c | 1 - src/fileio.c | 4 ---- src/keyboard.c | 5 +---- src/keymap.c | 4 ++-- src/term.c | 4 ---- src/xfns.c | 2 -- src/xsmfns.c | 2 ++ 13 files changed, 27 insertions(+), 29 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 67c17cde8cb..6ecfb283ff6 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,5 +1,8 @@ 2013-03-13 Paul Eggert + Static checking by Sun C 5.12. + * etags.c (analyse_regex): Omit unreachable code. + * movemail.c (main): Call umask on all systems. This is OK since Emacs already assumes umask elsewhere. Don't grant more read permissions than necessary. diff --git a/lib-src/etags.c b/lib-src/etags.c index c1e12e95da4..27a853a954a 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c @@ -5628,10 +5628,7 @@ analyse_regex (char *regex_arg) /* regexfile is a file containing regexps, one per line. */ regexfp = fopen (regexfile, "r"); if (regexfp == NULL) - { - pfatal (regexfile); - return; - } + pfatal (regexfile); linebuffer_init (®exbuf); while (readline_internal (®exbuf, regexfp) > 0) analyse_regex (regexbuf.buffer); diff --git a/src/ChangeLog b/src/ChangeLog index c0e6bd93fd0..7642393bb01 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,20 @@ 2013-03-13 Paul Eggert + Static checking by Sun C 5.12. + * alloc.c (buffer_memory_full) [REL_ALLOC]: + * bytecode.c (exec_byte_code): + * dispnew.c (init_display): + * eval.c (error): + * fileio.c (Fsubstitute_in_file_name): + * keyboard.c (Fevent_convert_list): + * keymap.c (Fsingle_key_description): + * term.c (maybe_fatal, fatal): + * xfns.c (Fx_display_backing_store, Fx_display_visual_class): + * xsmfns.c (Fhandle_save_session): + Omit unreachable code. + * keymap.c (map_keymap_char_table_item): Cast void * to + a function pointer type; the C Standard requires this. + * sysdep.c: Remove a use of BSD_SYSTEM, which I'm trying to phase out. Include unconditionally, as that works elsewhere and is simpler here. Include if DARWIN_OS || diff --git a/src/alloc.c b/src/alloc.c index 80086433e65..b2703c5f961 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -422,11 +422,11 @@ buffer_memory_full (ptrdiff_t nbytes) #ifndef REL_ALLOC memory_full (nbytes); -#endif - +#else /* This used to call error, but if we've run out of memory, we could get infinite recursion trying to build the string. */ xsignal (Qnil, Vmemory_signal_data); +#endif } /* A common multiple of the positive integers A and B. Ideally this diff --git a/src/bytecode.c b/src/bytecode.c index 628c4d90cf3..acb96c1e61b 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -755,7 +755,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, { BEFORE_POTENTIAL_GC (); wrong_type_argument (Qlistp, v1); - AFTER_POTENTIAL_GC (); } NEXT; } @@ -790,7 +789,6 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, { BEFORE_POTENTIAL_GC (); wrong_type_argument (Qlistp, v1); - AFTER_POTENTIAL_GC (); } NEXT; } diff --git a/src/dispnew.c b/src/dispnew.c index 9335365bc71..47adab6b8f7 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6100,10 +6100,7 @@ init_display (void) /* If no window system has been specified, try to use the terminal. */ if (! isatty (0)) - { - fatal ("standard input is not a tty"); - exit (1); - } + fatal ("standard input is not a tty"); #ifdef WINDOWSNT terminal_type = "w32console"; diff --git a/src/eval.c b/src/eval.c index 5db6f9d0bf3..69483a9b205 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1690,7 +1690,6 @@ error (const char *m, ...) va_list ap; va_start (ap, m); verror (m, ap); - va_end (ap); } DEFUN ("commandp", Fcommandp, Scommandp, 1, 2, 0, diff --git a/src/fileio.c b/src/fileio.c index d7363077b35..8937f7ca477 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1850,9 +1850,6 @@ those `/' is discarded. */) error ("Missing \"}\" in environment-variable substitution"); badvar: error ("Substituting nonexistent environment variable \"%s\"", target); - - /* NOTREACHED */ - return Qnil; } /* A slightly faster and more convenient way to get @@ -3305,7 +3302,6 @@ Use the current time if TIMESTAMP is nil. TIMESTAMP is in the format of return Qnil; #endif report_file_error ("Setting file times", Fcons (absname, Qnil)); - return Qnil; } } diff --git a/src/keyboard.c b/src/keyboard.c index fe8b45a0130..e43b7a73172 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -6552,10 +6552,7 @@ has the same base event type and all the specified modifiers. */) else if (SYMBOLP (base)) return apply_modifiers (modifiers, base); else - { - error ("Invalid base event"); - return Qnil; - } + error ("Invalid base event"); } /* Try to recognize SYMBOL as a modifier name. diff --git a/src/keymap.c b/src/keymap.c index 922c1703edf..00eefb375ef 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -565,7 +565,8 @@ map_keymap_char_table_item (Lisp_Object args, Lisp_Object key, Lisp_Object val) { if (!NILP (val)) { - map_keymap_function_t fun = XSAVE_POINTER (args, 0); + map_keymap_function_t fun + = (map_keymap_function_t) XSAVE_POINTER (args, 0); /* If the key is a range, make a copy since map_char_table modifies it in place. */ if (CONSP (key)) @@ -2310,7 +2311,6 @@ around function keys and event symbols. */) return Fcopy_sequence (key); else error ("KEY must be an integer, cons, symbol, or string"); - return Qnil; } static char * diff --git a/src/term.c b/src/term.c index 822b74aa44e..38706602a02 100644 --- a/src/term.c +++ b/src/term.c @@ -3426,9 +3426,6 @@ maybe_fatal (int must_succeed, struct terminal *terminal, vfatal (str2, ap); else verror (str1, ap); - - va_end (ap); - emacs_abort (); } void @@ -3437,7 +3434,6 @@ fatal (const char *str, ...) va_list ap; va_start (ap, str); vfatal (str, ap); - va_end (ap); } diff --git a/src/xfns.c b/src/xfns.c index a6a56c8c5e1..100fd81a155 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3769,7 +3769,6 @@ If omitted or nil, that stands for the selected frame's display. */) default: error ("Strange value for BackingStore parameter of screen"); - result = Qnil; } return result; @@ -3811,7 +3810,6 @@ If omitted or nil, that stands for the selected frame's display. */) break; default: error ("Display has an unknown visual class"); - result = Qnil; } return result; diff --git a/src/xsmfns.c b/src/xsmfns.c index fe2dfbaf83e..cb7122202df 100644 --- a/src/xsmfns.c +++ b/src/xsmfns.c @@ -514,9 +514,11 @@ Do not call this function yourself. */) prevent. Fix this in next version. */ Fkill_emacs (Qnil); +#if 0 /* This will not be reached, but we want kill-emacs-hook to be run. */ SmcCloseConnection (smc_conn, 0, 0); ice_connection_closed (); +#endif } return Qnil; -- 2.39.2