This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v5] C++ify gdb/common/environ.c
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: Simon Marchi <simon dot marchi at polymtl dot ca>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Mon, 19 Jun 2017 12:19:28 -0400
- Subject: Re: [PATCH v5] C++ify gdb/common/environ.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AF50E80C1D
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AF50E80C1D
- References: <20170413040455.23996-1-sergiodj@redhat.com> <20170616222315.12779-1-sergiodj@redhat.com> <4e43c71a2ac4aa229bb262e18dec668c@polymtl.ca> <87tw3cy5h7.fsf@redhat.com> <d0759537-8bd5-0fba-3ee2-ca325be0c89b@redhat.com>
On Monday, June 19 2017, Pedro Alves wrote:
> On 06/19/2017 05:19 AM, Sergio Durigan Junior wrote:
>
>> I
>> think it also makes a lot more sense to always initialize the vector
>> with a NULL element, because this means we're correctly dealing with the
>> case where there's no environment variable to be passed to the inferior.
>
> This sentence confuses me, because I don't understand what you mean
> by "correctly" here. What was incorrect?
What I mean is that the internal state of the vector is correct from the
get-go. As you said in another message, the environment vector passed
to the exec* family of syscalls should contain at least one element,
NULL. This means we can make sure that the vector generated by the API
(via the envp method) obeys this rule, or that the internal vector
(m_environ_vector) obeys this rule. I prefer the second method, because
it leaves everything (internal and external) in a correct state.
I don't have any advanced C++ arguments to base my opinion on, and I am
well aware that this means preallocating things that maybe didn't need
to be allocated, but I still prefer keeping the NULL element there
because it makes more sense to me.
My half-cent to this discussion.
Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/