Re: [Patch] Fix build problem with system call in compile/compile.c

Joel Brobecker
2015-01-06T04:16:43Z

> 2015-01-05 Steve Ellcey <sellcey@imgtec.com>
>
> * compile/compile.c (do_rmdir): Assign return value of system call.

If we go through with a patch that eliminates the warning without
actually doing anything about it, I'd request that a comment be
added that explains why we're allowing ourselves to do so. In this
case, as Yao explains, we're in the middle of a discussion about
how to better write that code.

> diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c
> index 1d18bd7..f9f03f1 100644
> --- a/gdb/compile/compile.c
> +++ b/gdb/compile/compile.c
> @@ -169,10 +169,12 @@ do_rmdir (void *arg)
> {
> const char *dir = arg;
> char *zap;
> + int i;
>
> gdb_assert (strncmp (dir, TMP_PREFIX, strlen (TMP_PREFIX)) == 0);
> zap = concat ("rm -rf ", dir, (char *) NULL);
> - system (zap);
> + /* GCC may generate warning if we ignore the return value of system call. */
> + i = system (zap);
> }
>
> /* Return the name of the temporary directory to use for .o files, and

Does it work to cast the result of the call to system to (void)
instead? In your case, I fear that you'd be exchanging one warning
(return value being ignored) by another (value assigned but never
used).

--
Joel