Re: [PATCH] am: ignore return value of write_file()
- From
Jeff King <peff@peff.net>
- Date
- Jul 8, 2016, 06:56 UTC
- Message-ID
- <20160708065650.GA10664@sigill.intra.peff.net>
- In-Reply-To
- <alpine.DEB.2.20.1607080834340.6426@virtualbox>
On Fri, Jul 08, 2016 at 08:37:35AM +0200, Johannes Schindelin wrote:
Show 13 quoted lines
> > We have two forms of write_file(): one that dies, and one > > that returns an error. However, the latter has only a single > > caller, which immediately dies anyway (after producing a > > message that is not really any more informative than > > write_file's generic die(), and arguably worse because it > > does not give the actual filename). > > This is more an illustration of unnecessarily duplicated code, isn't it? > There are *tons* of instances in Git's code where writing to a file is > implemented separately (and differently). > > It would make tons of sense to consolidate all of these instances, > methinks. The diffstat should look *very* pleasing.
I grepped for O_WRONLY, and there are fewer instances than I would have thought. Most of the obvious write_file() candidates are in the merge code, which is probably why you saw so many of them. :)
I started at converting a few sites, but it's actually a little awkward because they all have strbufs (with a ptr/len combo that _could_ contain NULs, but probably doesn't), and write_file() wants to take a format string.
I think we can clean that up, though. I'll hopefully have a series in a few minutes.
-Peff