Thread (47 messages) 47 messages, 7 authors, 2022-07-01

Re: [PATCH 1/2] archive: replace write_or_die() calls with write_block_or_die()

From: Jeff King <hidden>
Date: 2019-05-01 18:07:56

On Fri, Apr 26, 2019 at 10:28:12AM -0400, Johannes Schindelin wrote:
quoted
quoted
+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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help