From 67342916c9fd6fffe142539a3aba4601d005e839 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 3 Feb 2011 11:29:35 -0800 Subject: [PATCH 1/1] allow C code to suppress warnings about ignored return values --- ChangeLog | 6 ++++ Makefile.in | 2 +- configure | 91 +++++++++++++++++++++++++------------------------ lib/Makefile.in | 4 +-- lib/gnulib.mk | 8 ++++- m4/gl-comp.m4 | 4 +++ src/ChangeLog | 13 +++++++ src/sysdep.c | 7 ++-- 8 files changed, 84 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 178c8d8e5d..7b693be069 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-02-03 Paul Eggert + + allow C code to suppress warnings about ignored return values + * Makefile.in (GNULIB_MODULES): Add ignore-value. + * configure, lib/Makefile.in, lib/gnulib.mk, m4/gl-comp.m4: Regenerate. + 2011-01-31 Chong Yidong * configure.in: Test existence of xaw3d library, not just the diff --git a/Makefile.in b/Makefile.in index e3d2849940..e8206a6f01 100644 --- a/Makefile.in +++ b/Makefile.in @@ -330,7 +330,7 @@ DOS_gnulib_comp.m4 = gl-comp.m4 # Update modules from gnulib, for maintainers, who should have it in # $(gnulib_srcdir) (relative to $(srcdir) and should have build tools # as per $(gnulib_srcdir)/DEPENDENCIES. -GNULIB_MODULES = dtoastr getopt-gnu mktime strftime +GNULIB_MODULES = dtoastr getopt-gnu ignore-value mktime strftime GNULIB_TOOL_FLAGS = \ --import --no-changelog --no-vc-files --makefile-name=gnulib.mk sync-from-gnulib: $(gnulib_srcdir) diff --git a/configure b/configure index 624981c8c0..a1ca4cf7a3 100755 --- a/configure +++ b/configure @@ -5826,6 +5826,7 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } # Code from module getopt-gnu: # Code from module getopt-posix: # Code from module gettext-h: + # Code from module ignore-value: # Code from module include_next: # Code from module intprops: # Code from module mktime: @@ -10597,7 +10598,7 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for XawScrollbarSetThumb in -lXaw3d" >&5 $as_echo_n "checking for XawScrollbarSetThumb in -lXaw3d... " >&6; } -if test "${ac_cv_lib_Xaw3d_XawScrollbarSetThumb+set}" = set; then : +if ${ac_cv_lib_Xaw3d_XawScrollbarSetThumb+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10631,7 +10632,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_Xaw3d_XawScrollbarSetThumb" >&5 $as_echo "$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" >&6; } -if test "x$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" = x""yes; then : +if test "x$ac_cv_lib_Xaw3d_XawScrollbarSetThumb" = xyes; then : emacs_cv_xaw3d=yes else emacs_cv_xaw3d=no @@ -14330,6 +14331,48 @@ $as_echo "#define __GETOPT_PREFIX rpl_" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + GNULIB_MKTIME=0; GNULIB_NANOSLEEP=0; @@ -14404,48 +14447,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 -$as_echo_n "checking for inline... " >&6; } -if ${ac_cv_c_inline+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_cv_c_inline=no -for ac_kw in inline __inline__ __inline; do - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifndef __cplusplus -typedef int foo_t; -static $ac_kw foo_t static_foo () {return 0; } -$ac_kw foo_t foo () {return 0; } -#endif - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_c_inline=$ac_kw -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_inline" != no && break -done - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 -$as_echo "$ac_cv_c_inline" >&6; } - -case $ac_cv_c_inline in - inline | yes) ;; - *) - case $ac_cv_c_inline in - no) ac_val=;; - *) ac_val=$ac_cv_c_inline;; - esac - cat >>confdefs.h <<_ACEOF -#ifndef __cplusplus -#define inline $ac_val -#endif -_ACEOF - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : @@ -14888,6 +14889,8 @@ fi # Code from module gettext-h: + # Code from module ignore-value: + # Code from module include_next: # Code from module intprops: # Code from module mktime: diff --git a/lib/Makefile.in b/lib/Makefile.in index 7cd9841746..e50f9b31ef 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -24,7 +24,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getopt-gnu mktime strftime +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getopt-gnu ignore-value mktime strftime VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ @@ -483,7 +483,7 @@ MOSTLYCLEANFILES = core *.stackdump arg-nonnull.h arg-nonnull.h-t \ unistd.h-t warn-on-use.h warn-on-use.h-t noinst_LIBRARIES = libgnu.a DEFAULT_INCLUDES = -I. -I../src -I$(top_srcdir)/src -libgnu_a_SOURCES = dtoastr.c gettext.h +libgnu_a_SOURCES = dtoastr.c gettext.h ignore-value.h libgnu_a_LIBADD = $(gl_LIBOBJS) libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) EXTRA_libgnu_a_SOURCES = ftoastr.c getopt.c getopt1.c mktime.c \ diff --git a/lib/gnulib.mk b/lib/gnulib.mk index ea6759e453..af628c8d30 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getopt-gnu mktime strftime +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files dtoastr getopt-gnu ignore-value mktime strftime MOSTLYCLEANFILES += core *.stackdump @@ -111,6 +111,12 @@ libgnu_a_SOURCES += gettext.h ## end gnulib module gettext-h +## begin gnulib module ignore-value + +libgnu_a_SOURCES += ignore-value.h + +## end gnulib module ignore-value + ## begin gnulib module intprops diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4 index e512191890..4bd213cdbd 100644 --- a/m4/gl-comp.m4 +++ b/m4/gl-comp.m4 @@ -34,6 +34,7 @@ AC_DEFUN([gl_EARLY], # Code from module getopt-gnu: # Code from module getopt-posix: # Code from module gettext-h: + # Code from module ignore-value: # Code from module include_next: # Code from module intprops: # Code from module mktime: @@ -76,6 +77,8 @@ AC_DEFUN([gl_INIT], # Code from module gettext-h: AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) + # Code from module ignore-value: + AC_REQUIRE([AC_C_INLINE]) # Code from module include_next: # Code from module intprops: # Code from module mktime: @@ -248,6 +251,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/getopt1.c lib/getopt_int.h lib/gettext.h + lib/ignore-value.h lib/intprops.h lib/mktime-internal.h lib/mktime.c diff --git a/src/ChangeLog b/src/ChangeLog index aee41f57ac..a65fc5730d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2011-02-03 Paul Eggert + + allow C code to suppress warnings about ignored return values + + We need to go through the code and for each such warning, either + fix the code to pay attention to the returned value, or tell GCC + that we really do want to ignore the returned value. Here is one + example of how to do the latter. + * sysdep.c: Include . + (sys_subshell): Suppress an undesirable warning about not checking + the returned value of 'write', as there's nothing useful one can + do with that returned value. + 2011-02-03 Jan Djärv * xterm.c (x_connection_closed): Remove all calls that calls diff --git a/src/sysdep.c b/src/sysdep.c index 5f82d2d534..53b7f39171 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -31,6 +31,8 @@ along with GNU Emacs. If not, see . */ #endif /* HAVE_LIMITS_H */ #include +#include + #include "lisp.h" #include "sysselect.h" #include "blockinput.h" @@ -263,7 +265,7 @@ void init_baud_rate (int fd) { int emacs_ospeed; - + if (noninteractive) emacs_ospeed = 0; else @@ -578,7 +580,7 @@ sys_subshell (void) write (1, "Can't execute subshell", 22); #else /* not WINDOWSNT */ execlp (sh, sh, (char *) 0); - write (1, "Can't execute subshell", 22); + ignore_value (write (1, "Can't execute subshell", 22)); _exit (1); #endif /* not WINDOWSNT */ #endif /* not MSDOS */ @@ -3058,4 +3060,3 @@ system_process_attributes (Lisp_Object pid) } #endif /* !defined (WINDOWSNT) */ - -- 2.20.1