From: Andreas Schwab <schwab@linux-m68k.org>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>,
gdb-patches@sourceware.org
Subject: Re: [RFA] (cli/cli-cmds.c) ARI fix: Avoid assignment inside if statement
Date: Mon, 24 Dec 2012 10:22:00 -0000 [thread overview]
Message-ID: <m2zk13vjfx.fsf@igel.home> (raw)
In-Reply-To: <20121224041701.GQ5370@adacore.com> (Joel Brobecker's message of "Mon, 24 Dec 2012 08:17:01 +0400")
Joel Brobecker <brobecker@adacore.com> writes:
>> Index: src/gdb/cli/cli-cmds.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
>> retrieving revision 1.143
>> diff -u -p -r1.143 cli-cmds.c
>> --- src/gdb/cli/cli-cmds.c 18 Dec 2012 19:27:35 -0000 1.143
>> +++ src/gdb/cli/cli-cmds.c 20 Dec 2012 16:10:27 -0000
>> @@ -724,11 +724,13 @@ shell_escape (char *arg, int from_tty)
>> #else /* Can fork. */
>> int status, pid;
>>
>> - if ((pid = vfork ()) == 0)
>> + pid = vfork ();
>> + if (pid == 0)
>> {
>> const char *p, *user_shell;
>>
>> - if ((user_shell = (char *) getenv ("SHELL")) == NULL)
>> + user_shell = (char *) getenv ("SHELL");
>> + if (user_shell == NULL)
>> user_shell = "/bin/sh";
>>
>> /* Get the name of the shell for arg0. */
>> @@ -837,7 +839,8 @@ edit_command (char *arg, int from_tty)
>> error (_("No line number known for %s."), arg);
>> }
>>
>> - if ((editor = (char *) getenv ("EDITOR")) == NULL)
>> + editor = (char *) getenv ("EDITOR");
>
> According to POSIX, getenv returns char *, so I do not think
> that the cast is necessary. Let's try without and see what happens...
Even more so as editor should really be const char * (and user_shell
already is).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2012-12-24 10:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-23 19:00 Pierre Muller
2012-12-24 4:17 ` Joel Brobecker
2012-12-24 10:22 ` Andreas Schwab [this message]
[not found] <001201cde13f$af3ad4b0$0db07e10$%muller@ics-cnrs.unistra.fr>
2012-12-23 19:29 ` Eli Zaretskii
2012-12-23 21:58 ` Pierre Muller
2012-12-23 22:28 ` Andreas Schwab
2012-12-24 3:41 ` Eli Zaretskii
2012-12-24 10:17 ` Andreas Schwab
2013-01-10 12:28 ` Pierre Muller
2013-01-11 4:29 ` Joel Brobecker
2012-12-23 22:28 ` Sergio Durigan Junior
2012-12-24 4:11 ` 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=m2zk13vjfx.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=pierre.muller@ics-cnrs.unistra.fr \
/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