From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25901 invoked by alias); 24 Dec 2012 10:22:19 -0000 Received: (qmail 25892 invoked by uid 22791); 24 Dec 2012 10:22:18 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Dec 2012 10:22:13 +0000 Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3YVGhh3CFYz3hhYG; Mon, 24 Dec 2012 11:22:12 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 3YVGhh0FqDzbbcc; Mon, 24 Dec 2012 11:22:12 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.180]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavisd-new, port 10024) with ESMTP id iM_8RKBAfXJI; Mon, 24 Dec 2012 11:17:56 +0100 (CET) X-Auth-Info: knFVsn2eoOrQ7K1NqB9hxJniwRw7Ty7ptTMmEtuMn0I= Received: from igel.home (ppp-93-104-134-127.dynamic.mnet-online.de [93.104.134.127]) by mail.mnet-online.de (Postfix) with ESMTPA; Mon, 24 Dec 2012 11:22:11 +0100 (CET) Received: by igel.home (Postfix, from userid 501) id 004F1CA2A2; Mon, 24 Dec 2012 11:22:10 +0100 (CET) From: Andreas Schwab To: Joel Brobecker Cc: Pierre Muller , gdb-patches@sourceware.org Subject: Re: [RFA] (cli/cli-cmds.c) ARI fix: Avoid assignment inside if statement References: <001201cde13f$af3ad4b0$0db07e10$@muller@ics-cnrs.unistra.fr> <20121224041701.GQ5370@adacore.com> X-Yow: Are you selling NYLON OIL WELLS?? If so, we can use TWO DOZEN!! Date: Mon, 24 Dec 2012 10:22:00 -0000 In-Reply-To: <20121224041701.GQ5370@adacore.com> (Joel Brobecker's message of "Mon, 24 Dec 2012 08:17:01 +0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00806.txt.bz2 Joel Brobecker 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."