git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Simon Ruderich <simon@ruderich.org>,
	"git@vger.kernel.org" <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Yaroslav Halchenko <yoh@onerussian.com>
Subject: Re: [PATCH] strbuf: clear errno before calling getdelim(3)
Date: Sun, 13 Aug 2017 01:58:53 -0400	[thread overview]
Message-ID: <20170813055853.vrrfot3ijrpjk2rv@sigill.intra.peff.net> (raw)
In-Reply-To: <4bf18555-f8ea-a3f6-5204-b02bfd8f1ff9@web.de>

On Sun, Aug 13, 2017 at 07:51:34AM +0200, René Scharfe wrote:

> Am 13.08.2017 um 06:32 schrieb Jeff King:
> > On Sat, Aug 12, 2017 at 01:57:06PM +0200, René Scharfe wrote:
> > 
> >> But we probably want to check for other errors.  They look unlikely
> >> enough that we may get away with something like this:
> >>
> >> 	-	if (errno == ENOMEM)
> >> 	-		die("Out of memory, getdelim failed");
> >> 	+	if (errno || ferror(fp))
> >> 	+		die_errno(_("getdelim failed"));
> >>
> >> NB: The other errors are EINVAL (input pointers are NULL or the
> >> stream is invalid) and EOVERFLOW (read more than fits into ssize_t)
> >> according to POSIX and the Linux manpage.
> > 
> > Can't we also get any of the errors that fgetc() would return. I.e., any
> > normal read errors? We should return EOF on those, not die (and the
> > caller can check ferror()).
> 
> Yes, we can get those as well, and leaving error checking to the caller
> is a flexible way to handle them.  
> 
> Many of the existing callers don't seem to be bother, though.

Yes, but keep in mind that we need to match the non-getdelim()
implementation here (which itself tries to behave like more or less like
a dynamic fgets, including the eof/error handling). Because the callers
don't know which one they're getting.

-Peff

      reply	other threads:[~2017-08-13  5:58 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 17:39 fatal: Out of memory, getdelim failed under NFS mounts Yaroslav Halchenko
2017-08-10 13:27 ` René Scharfe
2017-08-10 14:43   ` Yaroslav Halchenko
2017-08-10 19:44     ` René Scharfe
2017-08-10 18:56   ` Junio C Hamano
2017-08-10 19:44     ` Yaroslav Halchenko
2017-08-10 19:58     ` René Scharfe
2017-08-10 20:05       ` Jeff King
2017-08-10 20:29         ` Yaroslav Halchenko
2017-08-10 20:56         ` [PATCH] strbuf: clear errno before calling getdelim(3) René Scharfe
2017-08-10 21:02           ` Jeff King
2017-08-10 21:35             ` Yaroslav Halchenko
2017-08-10 21:41           ` Junio C Hamano
2017-08-11  7:50           ` Simon Ruderich
2017-08-11  8:52             ` René Scharfe
2017-08-12 10:02               ` Simon Ruderich
2017-08-12 11:57                 ` René Scharfe
2017-08-12 12:21                   ` René Scharfe
2017-08-13  4:32                   ` Jeff King
2017-08-13  5:51                     ` René Scharfe
2017-08-13  5:58                       ` Jeff King [this message]

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=20170813055853.vrrfot3ijrpjk2rv@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=l.s.r@web.de \
    --cc=simon@ruderich.org \
    --cc=yoh@onerussian.com \
    /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).