This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] gdb/compile/compile.c: Check return value to avoid compiler warning


Under Ubuntu 12, need check the return value of system(), or it will
report warning:

  gcc -g -O2   -I. -I../../binutils-gdb/gdb -I../../binutils-gdb/gdb/common -I../../binutils-gdb/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../binutils-gdb/gdb/../include/opcode -I../../binutils-gdb/gdb/../opcodes/.. -I../../binutils-gdb/gdb/../readline/.. -I../bfd -I../../binutils-gdb/gdb/../bfd -I../../binutils-gdb/gdb/../include -I../libdecnumber -I../../binutils-gdb/gdb/../libdecnumber  -I../../binutils-gdb/gdb/gnulib/import -Ibuild-gnulib/import   -DTUI=1  -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type -Wold-style-declaration -Wold-style-definition -Wformat-nonliteral -Werror -c -o compile.o -MT compile.o -MMD -MP -MF .deps/compile.Tpo ../../binutils-gdb/gdb/compile/compile.c
  ../../binutils-gdb/gdb/compile/compile.c: In function âdo_rmdirâ:
  ../../binutils-gdb/gdb/compile/compile.c:175:10: error: ignoring return value of âsystemâ, declared with attribute warn_unused_result [-Werror=unused-result]
  cc1: all warnings being treated as errors
  make[2]: *** [compile.o] Error 1
  make[2]: Leaving directory `/upstream/build-binutils-s390/gdb'
  make[1]: *** [all-gdb] Error 2
  make[1]: Leaving directory `/upstream/build-binutils-s390'
  make: *** [all] Error 2

Also free 'zap', after finish using.


2015-01-02  Chen Gang  <gang.chen.5i5j@gmail.com>

	* compile/compile.c (do_rmdir): Check return value to avoid
	compiler warning, and free 'zap' after finish using.
---
 gdb/compile/compile.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 1d18bd7..bd99040 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -172,7 +172,9 @@ do_rmdir (void *arg)
   
   gdb_assert (strncmp (dir, TMP_PREFIX, strlen (TMP_PREFIX)) == 0);
   zap = concat ("rm -rf ", dir, (char *) NULL);
-  system (zap);
+  if (system (zap))
+    warning (_("Could not remove temporary directory %s"), dir);
+  XDELETEVEC (zap);
 }
 
 /* Return the name of the temporary directory to use for .o files, and
-- 
1.7.9.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]