From: Pedro Alves <palves@redhat.com>
To: Chen Gang S <gang.chen@sunrus.com.cn>, sellcey@imgtec.com
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>,
"Maciej W. Rozycki" <macro@linux-mips.org>,
Joel Brobecker <brobecker@adacore.com>,
gdb-patches@sourceware.org, Yao Qi <yao@codesourcery.com>
Subject: Re: [Patch] Fix build problem with system call in compile/compile.c
Date: Fri, 09 Jan 2015 10:11:00 -0000 [thread overview]
Message-ID: <54AFA92C.8010108@redhat.com> (raw)
In-Reply-To: <54AF50E4.3080901@sunrus.com.cn>
On 01/09/2015 03:54 AM, Chen Gang S wrote:
> On 1/9/15 08:10, Steve Ellcey wrote:
>> On Thu, 2015-01-08 at 23:22 +0000, Pedro Alves wrote:
>>> On 01/08/2015 10:12 PM, Steve Ellcey wrote:
>>>
>>>> I haven't seen any objection to
>>>> Chen's patch but I haven't seen an official approval either.
>>>
>>> FAOD, Chen's patch is OK.
>>>
>>> Thanks,
>>> Pedro Alves
>>>
>>
>> Excellent. Chen Gang, do you have write access to check in this patch
>> or do you need someone to do the check in for you?
>>
>
> Excuse me, I guess, I can not check in, welcome any other members help to
> check in for me.
I was going to apply it as is, but I recalled that the return
of "system" is really a 'wait' status:
> + if (system (zap))
> + warning (_("Could not remove temporary directory %s"), dir);
so I tweaked the patch accordingly, and pushed it, as below.
------------
From: Chen Gang <gang.chen@sunrus.com.cn>
Subject: [PATCH] gdb/compile/compile.c: Check return value of 'system' to
avoid compiler warning
Under Ubuntu 12, we need to check the return value of system(), or the
compiler warns:
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, 'zap' is leaking.
2015-01-09 Chen Gang <gang.chen.5i5j@gmail.com>
Pedro Alves <palves@redhat.com>
* compile/compile.c: Include "gdb_wait.h".
(do_rmdir): Check return value, and free 'zap'.
---
gdb/compile/compile.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
index 1d18bd7..ccac49d 100644
--- a/gdb/compile/compile.c
+++ b/gdb/compile/compile.c
@@ -37,6 +37,7 @@
#include "filestuff.h"
#include "target.h"
#include "osabi.h"
+#include "gdb_wait.h"
\f
@@ -169,10 +170,14 @@ do_rmdir (void *arg)
{
const char *dir = arg;
char *zap;
-
+ int wstat;
+
gdb_assert (strncmp (dir, TMP_PREFIX, strlen (TMP_PREFIX)) == 0);
zap = concat ("rm -rf ", dir, (char *) NULL);
- system (zap);
+ wstat = system (zap);
+ if (wstat == -1 || !WIFEXITED (wstat) || WEXITSTATUS (wstat) != 0)
+ warning (_("Could not remove temporary directory %s"), dir);
+ XDELETEVEC (zap);
}
/* Return the name of the temporary directory to use for .o files, and
--
1.9.3
next prev parent reply other threads:[~2015-01-09 10:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-06 0:44 Steve Ellcey
2015-01-06 3:09 ` Yao Qi
2015-01-06 4:16 ` Joel Brobecker
2015-01-06 16:04 ` Steve Ellcey
2015-01-07 4:14 ` Joel Brobecker
2015-01-07 18:36 ` Steve Ellcey
2015-01-07 19:01 ` Pedro Alves
2015-01-07 19:29 ` Maciej W. Rozycki
2015-01-07 19:35 ` Pedro Alves
2015-01-07 23:33 ` Maciej W. Rozycki
2015-01-08 21:12 ` Jan Kratochvil
2015-01-08 22:12 ` Steve Ellcey
2015-01-08 23:22 ` Pedro Alves
2015-01-09 0:10 ` Steve Ellcey
2015-01-09 3:47 ` Chen Gang S
2015-01-09 10:11 ` Pedro Alves [this message]
2015-01-09 10:46 ` Chen Gang S
2015-01-09 20:52 ` Chen Gang S
2015-01-09 21:53 ` Chen Gang S
2015-01-10 4:30 ` Joel Brobecker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54AFA92C.8010108@redhat.com \
--to=palves@redhat.com \
--cc=brobecker@adacore.com \
--cc=gang.chen@sunrus.com.cn \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=macro@linux-mips.org \
--cc=sellcey@imgtec.com \
--cc=yao@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox