Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "René Scharfe" <l.s.r@web.de>,
	"David Turner" <dturner@twosigma.com>,
	git@vger.kernel.org, jrnieder@gmail.com,
	"Duy Nguyen" <pclouds@gmail.com>
Subject: Re: [PATCH v2] xgethostname: handle long hostnames
Date: Tue, 18 Apr 2017 18:47:34 -0700	[thread overview]
Message-ID: <xmqqtw5lcgnd.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20170418161734.pa665rqwdtbnsj7f@sigill.intra.peff.net> (Jeff King's message of "Tue, 18 Apr 2017 12:17:34 -0400")

Jeff King <peff@peff.net> writes:

> I doubt that doing it in one call matters. It's not like stdio promises
> us any atomicity in the first place.
>
>> -			fscanf(fp, "%"SCNuMAX" %127c", &pid, locking_host) == 2 &&
>> +			fscanf(fp, "%"SCNuMAX" ", &pid) == 1 &&
>> +			!strbuf_getwholeline(&locking_host, fp, '\0') &&
>
> I don't think there is anything wrong with using fscanf here, but it has
> enough pitfalls in general that I don't really like its use as a parser
> (and the general lack of it in Git's code base seems to agree).
>
> I wonder if this should just read a line (or the whole file) into a
> strbuf and parse it there. That would better match our usual style, I
> think.

Yeah, I think it would be a good change.

  reply	other threads:[~2017-04-19  1:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-17 16:17 [PATCH v2] xgethostname: handle long hostnames David Turner
2017-04-18  1:19 ` Junio C Hamano
2017-04-18  1:41   ` Junio C Hamano
2017-04-18 16:07     ` René Scharfe
2017-04-18 16:17       ` Jeff King
2017-04-19  1:47         ` Junio C Hamano [this message]
2017-04-18 17:52       ` David Turner
2017-04-19  3:49         ` Junio C Hamano
2017-04-19  1:49       ` Junio C Hamano

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

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

  git send-email \
    --in-reply-to=xmqqtw5lcgnd.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=dturner@twosigma.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=l.s.r@web.de \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox