From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 80160 invoked by alias); 19 Jun 2017 04:15:48 -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 78601 invoked by uid 89); 19 Jun 2017 04:14:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,TRACKER_ID,T_RP_MATCHES_RCVD 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; Mon, 19 Jun 2017 04:14:40 +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 B117BC04B924; Mon, 19 Jun 2017 04:14:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B117BC04B924 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B117BC04B924 Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86C3A7C140; Mon, 19 Jun 2017 04:14:43 +0000 (UTC) From: Sergio Durigan Junior To: Simon Marchi Cc: GDB Patches , Pedro Alves Subject: Re: [PATCH] Use getenv instead of gdb_environ on mi-cmd-env.c References: <20170616221231.11852-1-sergiodj@redhat.com> <88e26ea4479a02c36d195d9f9e288eb0@polymtl.ca> Date: Mon, 19 Jun 2017 04:15:00 -0000 In-Reply-To: <88e26ea4479a02c36d195d9f9e288eb0@polymtl.ca> (Simon Marchi's message of "Sat, 17 Jun 2017 10:01:25 +0200") Message-ID: <87y3soy5ot.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00490.txt.bz2 On Saturday, June 17 2017, Simon Marchi wrote: > On 2017-06-17 00:12, Sergio Durigan Junior wrote: >> This is a spinoff of >> . >> mi-cmd-env.c is using the whole gdb_environ machinery in order to >> access just one variable, which can be easily replaced by a simple >> call to getenv. This patch does that, and doesn't cause regressions. >> >> gdb/ChangeLog: >> 2017-06-16 Sergio Durigan Junior >> >> * mi/mi-cm-env.c (_initialize_mi_cmd_env): Use getenv instead of >> gdb_environ to access an environment variable. >> --- >> gdb/ChangeLog | 5 +++++ >> gdb/mi/mi-cmd-env.c | 12 ++++-------- >> 2 files changed, 9 insertions(+), 8 deletions(-) >> >> diff --git a/gdb/ChangeLog b/gdb/ChangeLog >> index 9062067..f5bf474 100644 >> --- a/gdb/ChangeLog >> +++ b/gdb/ChangeLog >> @@ -1,3 +1,8 @@ >> +2017-06-16 Sergio Durigan Junior >> + >> + * mi/mi-cm-env.c (_initialize_mi_cmd_env): Use getenv instead of >> + gdb_environ to access an environment variable. >> + >> 2017-06-16 Alan Hayward >> Pedro Alves >> Yao Qi >> diff --git a/gdb/mi/mi-cmd-env.c b/gdb/mi/mi-cmd-env.c >> index 4093178..97be139 100644 >> --- a/gdb/mi/mi-cmd-env.c >> +++ b/gdb/mi/mi-cmd-env.c >> @@ -270,21 +270,17 @@ mi_cmd_inferior_tty_show (const char *command, >> char **argv, int argc) >> void >> _initialize_mi_cmd_env (void) >> { >> - struct gdb_environ *environment; >> const char *env; >> >> /* We want original execution path to reset to, if desired later. >> At this point, current inferior is not created, so cannot use >> - current_inferior ()->environment. Also, there's no obvious >> - place where this code can be moved such that it surely run >> - before any code possibly mangles original PATH. */ >> - environment = make_environ (); >> - init_environ (environment); >> - env = get_in_environ (environment, path_var_name); >> + current_inferior ()->environment. We use getenv here because it >> + is not necessary to create a whole new gdb_environ just for one >> + variable. */ >> + env = getenv (path_var_name); >> >> /* Can be null if path is not set. */ >> if (!env) >> env = ""; >> orig_path = xstrdup (env); >> - free_environ (environment); >> } > > LGTM. > Thanks, pushed. 1c8e01c96054973c50ec1dec2f220af4734e1de5 -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/