git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Andrey Okoshkin <a.okoshkin@samsung.com>
Cc: "Stefan Beller" <sbeller@google.com>, "Jeff King" <peff@peff.net>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Martin Ågren" <martin.agren@gmail.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	vmiklos@frugalware.org
Subject: Re: [PATCH v4] merge-recursive: check GIT_MERGE_VERBOSITY only once
Date: Tue, 31 Oct 2017 16:20:05 +0900	[thread overview]
Message-ID: <xmqqwp3byeai.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <ecb12f21-f26f-6905-1fdc-60d7c282cfe3@samsung.com> (Andrey Okoshkin's message of "Tue, 31 Oct 2017 10:13:00 +0300")

Andrey Okoshkin <a.okoshkin@samsung.com> writes:

> I think, the main benefits are:
> * Code is more readable, no duplicated calls with the same constant string
> argument.
> * Code is potentially safer, the second getenv() call may return another
> pointer value which could be NULL (and yes, this is an arguable point as it
> can be done only artificially).
>
>> For the sake of fairness, I would say that the resulting code may be
>> easier to follow and has one less instance of a constant string that
>> the compiler cannot statically check if we made a typo.  That's the
>> only benefit in this patch as far as I can see.
>> 
>> The original makes a call to see if the result is NULL, and then
>> makes the same call, expecting that we get the same result (not just
>> that it is not NULL, but it is the same verbosity request the end
>> user made via the environment as the one we checked earlier), and I
>> can understand that it feels a bit redundant and ugly.
>
> Yes, you absolutely right.

I am absolutely right when I say your "code is potentially safer" is
total BS.  The result from first getenv() call may be pointing at an
invalid piece of memory by the time it is used, if you are in a
situation in which not having the second getenv() matters
(i.e. somebody else is also mucking with getenv() at the same time).

So please update the log message so that the patch is not sold on
that basis.

Thanks.

  reply	other threads:[~2017-10-31  7:20 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20171024152727epcas2p4fb7dcf147e44aadf7733098151d469a5@epcas2p4.samsung.com>
2017-10-24 15:27 ` [PATCH] merge-recursive: check GIT_MERGE_VERBOSITY only once Andrey Okoshkin
2017-10-24 16:28   ` Stefan Beller
2017-10-24 16:45     ` Eric Sunshine
2017-10-24 17:11       ` Martin Ågren
2017-10-24 19:52         ` Jeff King
2017-10-25  1:48           ` Junio C Hamano
2017-10-25  4:07             ` Eric Sunshine
2017-10-25  7:27               ` Jeff King
2017-10-25 11:39                 ` [PATCH v2] " Andrey Okoshkin
2017-10-25 11:53                   ` Eric Sunshine
2017-10-25 12:27                     ` Andrey Okoshkin
2017-10-25 13:03                     ` [PATCH v3] " Andrey Okoshkin
2017-10-27 17:29                       ` Stefan Beller
2017-10-30  7:42                         ` [PATCH v4] " Andrey Okoshkin
2017-10-31  1:42                           ` Junio C Hamano
2017-10-31  2:26                             ` Junio C Hamano
2017-10-31  7:13                               ` Andrey Okoshkin
2017-10-31  7:20                                 ` Junio C Hamano [this message]
2017-10-31  9:09                                   ` [PATCH v5] " Andrey Okoshkin
2017-10-25 11:13           ` [PATCH] " Andrey Okoshkin
2017-10-25 10:49       ` Andrey Okoshkin
2017-10-25 10:49     ` Andrey Okoshkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwp3byeai.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=a.okoshkin@samsung.com \
    --cc=git@vger.kernel.org \
    --cc=martin.agren@gmail.com \
    --cc=peff@peff.net \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.com \
    --cc=vmiklos@frugalware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).