From: René Scharfe Date: Thu, 07 Aug 2025 19:51:17 GMT Subject: Re: [PATCH 2/4] archive-zip: remove unneccesarry condition in write_zip_entry() Message-ID: <7650da07-dd89-4e79-ac81-1c99f4700d9e@web.de> In-Reply-To: <20250804-toon-archive-zip-fix-v1-2-ca89858e5eaa@iotcl.com> On 8/4/25 6:56 PM, Toon Claes wrote: > The function write_or_die() can handle a length that's zero, thus we can > remove the condition that checks the value of `out_len` that surrounds > this call. The value shall never be negative as this would have caused > data being omitted in the deflated output. > > Co-authored-by: Justin Tobler > Signed-off-by: Toon Claes > --- > archive-zip.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/archive-zip.c b/archive-zip.c > index cc6d0cadd9..d41a12de5f 100644 > --- a/archive-zip.c > +++ b/archive-zip.c > @@ -478,11 +478,8 @@ static int write_zip_entry(struct archiver_args *args, > die(_("deflate error (%d)"), result); > out_len = zstream.next_out - compressed; > > - if (out_len > 0) { > - write_or_die(1, compressed, out_len); > - compressed_size += out_len; > - } > - > + write_or_die(1, compressed, out_len); > + compressed_size += out_len; > } > close_istream(stream); > if (readlen) > OK, less lines again, great! write_or_die() handles out_len == 0 just fine; this won't increase the number of syscalls we make. René