From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79409 invoked by alias); 13 Sep 2018 23:33:47 -0000 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 Received: (qmail 79395 invoked by uid 89); 13 Sep 2018 23:33:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Sep 2018 23:33:43 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC733308FC4F; Thu, 13 Sep 2018 23:33:42 +0000 (UTC) Received: from localhost (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80BFA5C1A1; Thu, 13 Sep 2018 23:33:42 +0000 (UTC) From: Sergio Durigan Junior To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Remove variable in get_startup_shell non-static References: <20180913223416.12824-1-tom@tromey.com> Date: Thu, 13 Sep 2018 23:33:00 -0000 In-Reply-To: <20180913223416.12824-1-tom@tromey.com> (Tom Tromey's message of "Thu, 13 Sep 2018 16:34:16 -0600") Message-ID: <87k1npotux.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00445.txt.bz2 On Thursday, September 13 2018, Tom Tromey wrote: > I noticed that a variable in get_startup_shell is "static". However, > I couldn't see any reason it ought to be, so this removes the > "static". IIRC this code was added by a patch of mine. I think your patch makes sense. Perhaps, since the SHELL can't change once you start GDB, this function could be made a bit smarter and check whether "ret" has been initialized or not (in order to call "getenv" just once), but really, that's not necessary at all, and your patch is totally fine. Thanks, > gdb/ChangeLog > 2018-09-13 Tom Tromey > > * nat/fork-inferior.c (get_startup_shell): Remove "static". > --- > gdb/ChangeLog | 4 ++++ > gdb/nat/fork-inferior.c | 4 +--- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c > index ea71aad25f7..40cd05a0f8f 100644 > --- a/gdb/nat/fork-inferior.c > +++ b/gdb/nat/fork-inferior.c > @@ -272,9 +272,7 @@ execv_argv::init_for_shell (const char *exec_file, > static const char * > get_startup_shell () > { > - static const char *ret; > - > - ret = getenv ("SHELL"); > + const char *ret = getenv ("SHELL"); > if (ret == NULL) > ret = SHELL_FILE; > > -- > 2.17.1 -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/