Re: [PATCH 1/2] config: check if config path is a file before parsing it
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Mar 3, 2017, 10:29 UTC
- Message-ID
- <CACsJy8CDOBUe7S3sYz=_tAJy2ajM5h2v+ZypD6Cr1uJo7XAnGQ@mail.gmail.com>
- In-Reply-To
- <20170303101503.lf2ub2c7i6w7kg3t@sigill.intra.peff.net>
On Fri, Mar 3, 2017 at 5:15 PM, Jeff King <peff@peff.net> wrote:
> But I do think option (a) is cleaner. The only trick is that for errno > to be valid, we need to make sure we check ferror() soon after seeing > the EOF return value. I suspect it would work OK in practice for the > git_config_from_file() case.
stdio error handling is a pain. Maybe we're better of with open() and mmap() (or even read_in_full)? I/O error handling would be at the beginning, not buried deep in the parser. Hmm.. since we already have "fgetc' version for config blobs, this could kill some code...
-- Duy