Message ID | 20180913223416.12824-1-tom@tromey.com |
---|---|
State | New, archived |
Headers |
Received: (qmail 99686 invoked by alias); 13 Sep 2018 22:35:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: <gdb-patches.sourceware.org> List-Unsubscribe: <mailto:gdb-patches-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:gdb-patches-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-help@sourceware.org>, <http://sourceware.org/ml/#faqs> Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 99631 invoked by uid 89); 13 Sep 2018 22:35:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.150.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Sep 2018 22:35:05 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway30.websitewelcome.com (Postfix) with ESMTP id BDFA8117A for <gdb-patches@sourceware.org>; Thu, 13 Sep 2018 17:35:02 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 0aBngdcSybXuJ0aCDgwPrC; Thu, 13 Sep 2018 17:35:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tEUT7tXITBVbn43LfDQymXXdUAe/G90pxEEXCFUWbzs=; b=Qw5r6KyIvqwkT4mxvnJR2vs+1V KXYUkpA58Hpu+ErQt85seImeUGg6T8NZRZtdAw730/ea0yeY+29PrpBPIHqaxixVt8hpcpQI/4/sI f3ZMmpK3NFU2fDGLX2etwRoCP; Received: from 97-122-189-157.hlrn.qwest.net ([97.122.189.157]:55078 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from <tom@tromey.com>) id 1g0aBn-003gwy-KJ; Thu, 13 Sep 2018 17:34:19 -0500 From: Tom Tromey <tom@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey <tom@tromey.com> Subject: [PATCH] Remove variable in get_startup_shell non-static Date: Thu, 13 Sep 2018 16:34:16 -0600 Message-Id: <20180913223416.12824-1-tom@tromey.com> |
Commit Message
Tom Tromey
Sept. 13, 2018, 10:34 p.m. UTC
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". gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * 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(-)
Comments
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 <tom@tromey.com> > > * 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" == Sergio Durigan Junior <sergiodj@redhat.com> writes:
Sergio> IIRC this code was added by a patch of mine. I think your patch makes
Sergio> sense. Perhaps, since the SHELL can't change once you start GDB, this
Sergio> function could be made a bit smarter and check whether "ret" has been
Sergio> initialized or not (in order to call "getenv" just once), but really,
Sergio> that's not necessary at all, and your patch is totally fine.
Thanks, I'm going to check it in.
Tom
>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:
Sergio> IIRC this code was added by a patch of mine. I think your patch makes
Sergio> sense. Perhaps, since the SHELL can't change once you start GDB, this
Sergio> function could be made a bit smarter and check whether "ret" has been
Sergio> initialized or not (in order to call "getenv" just once), but really,
Sergio> that's not necessary at all, and your patch is totally fine.
I poked a little at the macOS shell / SIP thing. One possible solution
is copying the shell, and in this situation it's convenient if
get_startup_shell does not cache. I already checked this in, but I
thought I'd mention it anyway in case someone was tempted to change it.
Tom
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;