From patchwork Fri Jan 2 02:40:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 4477 Received: (qmail 10188 invoked by alias); 2 Jan 2015 02:41:10 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10171 invoked by uid 89); 2 Jan 2015 02:41:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: out3140-249.mail.aliyun.com Received: from out3140-249.mail.aliyun.com (HELO out3140-249.mail.aliyun.com) (42.120.140.249) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Jan 2015 02:40:58 +0000 X-Alimail-AntiSpam: AC=SUSPECT; BC=0.7968556|0.08904865; BR=01201311R701b1; FP=0|0|0|0|0|-1|-1|-1; HT=r41g03020; MF=gang.chen@sunrus.com.cn; PH=DS; RN=1; RT=1; SR=0; Received: from 192.168.1.104(mailfrom:gang.chen@sunrus.com.cn ip:223.72.65.1) by smtp.aliyun-inc.com(10.147.11.249); Fri, 02 Jan 2015 10:40:43 +0800 Message-ID: <54A6052A.7070401@sunrus.com.cn> Date: Fri, 02 Jan 2015 10:40:42 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: [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 * 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