Re: [PATCH 1/2] archive: replace write_or_die() calls with write_block_or_die()
- From
Jeff King <peff@peff.net>
- Date
- May 1, 2019, 18:07 UTC
- Message-ID
- <20190501180752.GA4109@sigill.intra.peff.net>
- In-Reply-To
- <nycvar.QRO.7.76.6.1904261026070.45@tvgsbejvaqbjf.bet>
On Fri, Apr 26, 2019 at 10:28:12AM -0400, Johannes Schindelin wrote:
Show 16 quoted lines
> > > +static gzFile gzip;
> > > [...]
> > > + if (gzip) {
> >
> > Is it OK for us to ask about the truthiness of this opaque type? That
> > works if it's really a pointer behind the scenes, but it seems like it
> > would be equally OK for zlib to declare it as a struct.
> >
> > It looks OK in my version of zlib, and that library tends to be fairly
> > conservative so I wouldn't be surprised if it was that way back to the
> > beginning and remains that way for eternity. But it feels like a bad
> > pattern.
>
> It is even part of the public API that `gzFile` is `typedef`'d to a
> pointer. So I think in the interest of simplicity, I'll leave it at that
> (but I'll mention this in the commit message).I think that's probably OK. My biggest concern is that we'd notice if our assumption changes, but I think modern compilers would generally complain about checking a tautological truth value.
-Peff