From 3d5ee10aa258a500e0b70b5eabe9d58cb3ab051e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 3 Jun 2013 11:29:30 -0700 Subject: [PATCH] Fix minor problems found by static checking. * data.c (pure_write_error): Use xsignal2, not Fsignal, as Fsignal might return. * eval.c (set_backtrace_debug_on_exit): Now static. (backtrace_p, backtrace_top, backtrace_next, record_in_backtrace): No longer inline. EXTERN_INLINE is needed only for functions defined in .h files. Reindent function header as per GNU style. (backtrace_p, backtrace_top, backtrace_next): Mark EXTERNALLY_VISIBLE so they don't get optimized away by the compiler or linker. Add extern decls to pacify gcc -Wall. * frame.c, frame.h (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): Now static. * frame.c (free_monitors): Define only on platforms that need it. * nsterm.m (ns_term_init): * process.c (catch_child_signal): Don't worry about whether SIGCHLD is defined, as SIGCHLD is defined on all porting targets these days. * process.c, process.h (catch_child_signal): Make it extern only if NS_IMPL_GNUSTEP is defined. --- src/ChangeLog | 22 ++++++++++++++++++++++ src/data.c | 3 +-- src/eval.c | 23 ++++++++++++++++------- src/frame.c | 7 +++++-- src/frame.h | 2 -- src/nsterm.m | 8 ++++---- src/process.c | 5 +++-- src/process.h | 2 ++ 8 files changed, 53 insertions(+), 19 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a1aa4efcc86..b3b6f4730f0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,25 @@ +2013-06-03 Paul Eggert + + Fix minor problems found by static checking. + * data.c (pure_write_error): + Use xsignal2, not Fsignal, as Fsignal might return. + * eval.c (set_backtrace_debug_on_exit): Now static. + (backtrace_p, backtrace_top, backtrace_next, record_in_backtrace): + No longer inline. EXTERN_INLINE is needed only for functions + defined in .h files. Reindent function header as per GNU style. + (backtrace_p, backtrace_top, backtrace_next): + Mark EXTERNALLY_VISIBLE so they don't get optimized away by the + compiler or linker. Add extern decls to pacify gcc -Wall. + * frame.c, frame.h (Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource): + Now static. + * frame.c (free_monitors): Define only on platforms that need it. + * nsterm.m (ns_term_init): + * process.c (catch_child_signal): + Don't worry about whether SIGCHLD is defined, as SIGCHLD is + defined on all porting targets these days. + * process.c, process.h (catch_child_signal): + Make it extern only if NS_IMPL_GNUSTEP is defined. + 2013-06-03 Eli Zaretskii * w32.c (gettimeofday): Make the signature identical to prototype diff --git a/src/data.c b/src/data.c index fc66cea6497..9f756de014a 100644 --- a/src/data.c +++ b/src/data.c @@ -102,8 +102,7 @@ wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value) void pure_write_error (Lisp_Object obj) { - Fsignal (Qerror, Fcons (build_string ("Attempt to modify read-only object"), - Fcons (obj, Qnil))); + xsignal2 (Qerror, build_string ("Attempt to modify read-only object"), obj); } void diff --git a/src/eval.c b/src/eval.c index d6236b6edf2..d1d074df777 100644 --- a/src/eval.c +++ b/src/eval.c @@ -117,21 +117,29 @@ static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args); /* Functions to modify slots of backtrace records. */ -static void set_backtrace_args (struct specbinding *pdl, Lisp_Object *args) +static void +set_backtrace_args (struct specbinding *pdl, Lisp_Object *args) { eassert (pdl->kind == SPECPDL_BACKTRACE); pdl->v.bt.args = args; } -static void set_backtrace_nargs (struct specbinding *pdl, ptrdiff_t n) +static void +set_backtrace_nargs (struct specbinding *pdl, ptrdiff_t n) { eassert (pdl->kind == SPECPDL_BACKTRACE); pdl->v.bt.nargs = n; } -void set_backtrace_debug_on_exit (struct specbinding *pdl, bool doe) +static void +set_backtrace_debug_on_exit (struct specbinding *pdl, bool doe) { eassert (pdl->kind == SPECPDL_BACKTRACE); pdl->v.bt.debug_on_exit = doe; } /* Helper functions to scan the backtrace. */ -EXTERN_INLINE bool backtrace_p (struct specbinding *pdl) +bool backtrace_p (struct specbinding *) EXTERNALLY_VISIBLE; +struct specbinding *backtrace_top (void) EXTERNALLY_VISIBLE; +struct specbinding *backtrace_next (struct specbinding *pdl) EXTERNALLY_VISIBLE; + +bool backtrace_p (struct specbinding *pdl) { return pdl >= specpdl; } -EXTERN_INLINE struct specbinding *backtrace_top (void) +struct specbinding * +backtrace_top (void) { struct specbinding *pdl = specpdl_ptr - 1; while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE) @@ -139,7 +147,8 @@ EXTERN_INLINE struct specbinding *backtrace_top (void) return pdl; } -EXTERN_INLINE struct specbinding *backtrace_next (struct specbinding *pdl) +struct specbinding * +backtrace_next (struct specbinding *pdl) { pdl--; while (backtrace_p (pdl) && pdl->kind != SPECPDL_BACKTRACE) @@ -1925,7 +1934,7 @@ grow_specpdl (void) specpdl_ptr = specpdl + count; } -LISP_INLINE void +void record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs) { eassert (nargs >= UNEVALLED); diff --git a/src/frame.c b/src/frame.c index e88432b9802..a207ef690da 100644 --- a/src/frame.c +++ b/src/frame.c @@ -114,7 +114,7 @@ Lisp_Object Qface_set_after_frame_default; static Lisp_Object Qdelete_frame_functions; -Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; +static Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; #ifdef HAVE_WINDOW_SYSTEM static void x_report_frame_params (struct frame *, Lisp_Object *); @@ -167,7 +167,7 @@ struct frame * decode_window_system_frame (Lisp_Object frame) { struct frame *f = decode_live_frame (frame); - + if (!window_system_available (f)) error ("Window system frame should be used"); return f; @@ -4138,6 +4138,8 @@ selected frame. This is useful when `make-pointer-invisible' is set. */) #ifdef HAVE_WINDOW_SYSTEM +# if (defined HAVE_NS \ + || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR))) void free_monitors (struct MonitorInfo *monitors, int n_monitors) { @@ -4146,6 +4148,7 @@ free_monitors (struct MonitorInfo *monitors, int n_monitors) xfree (monitors[i].name); xfree (monitors); } +# endif Lisp_Object make_monitor_attribute_list (struct MonitorInfo *monitors, diff --git a/src/frame.h b/src/frame.h index 12aa48b2d92..31d3e73c3c3 100644 --- a/src/frame.h +++ b/src/frame.h @@ -1198,8 +1198,6 @@ extern Lisp_Object Qdisplay; extern Lisp_Object Qrun_hook_with_args; -extern Lisp_Object Qgeometry, Qworkarea, Qmm_size, Qframes, Qsource; - #ifdef HAVE_WINDOW_SYSTEM /* The class of this X application. */ diff --git a/src/nsterm.m b/src/nsterm.m index 9cf138837f6..93f693fe55e 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -4361,7 +4361,7 @@ ns_term_init (Lisp_Object display_name) [NSApp run]; ns_do_open_file = YES; -#if defined (NS_IMPL_GNUSTEP) && defined (SIGCHLD) +#ifdef NS_IMPL_GNUSTEP /* GNUstep steals SIGCHLD for use in NSTask, but we don't use NSTask. We must re-catch it so subprocess works. */ catch_child_signal (); @@ -5600,7 +5600,7 @@ not_in_argv (NSString *arg) #ifdef NS_IMPL_GNUSTEP gsextra = 3; #endif - + NSTRACE (windowWillResize); /*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ @@ -5666,7 +5666,7 @@ not_in_argv (NSString *arg) - (void)windowDidResize: (NSNotification *)notification { - if (! [self fsIsNative]) + if (! [self fsIsNative]) { NSWindow *theWindow = [notification object]; /* We can get notification on the non-FS window when in @@ -6115,7 +6115,7 @@ not_in_argv (NSString *arg) } } #endif - + - (void)toggleFullScreen: (id)sender { NSWindow *w, *fw; diff --git a/src/process.c b/src/process.c index 9df003fa3a3..8c4199e5eed 100644 --- a/src/process.c +++ b/src/process.c @@ -7029,14 +7029,15 @@ integer or floating point values. return system_process_attributes (pid); } +#ifndef NS_IMPL_GNUSTEP +static +#endif void catch_child_signal (void) { -#ifdef SIGCHLD struct sigaction action; emacs_sigaction_init (&action, deliver_child_signal); sigaction (SIGCHLD, &action, 0); -#endif } diff --git a/src/process.h b/src/process.h index 9455df18beb..0c4e17e68cf 100644 --- a/src/process.h +++ b/src/process.h @@ -217,6 +217,8 @@ extern void add_read_fd (int fd, fd_callback func, void *data); extern void delete_read_fd (int fd); extern void add_write_fd (int fd, fd_callback func, void *data); extern void delete_write_fd (int fd); +#ifdef NS_IMPL_GNUSTEP extern void catch_child_signal (void); +#endif INLINE_HEADER_END -- 2.39.2