git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Toon Claes <toon@iotcl.com>, git@vger.kernel.org
Cc: Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH 2/4] archive-zip: remove unneccesarry condition in write_zip_entry()
Date: Thu, 7 Aug 2025 21:51:17 +0200	[thread overview]
Message-ID: <7650da07-dd89-4e79-ac81-1c99f4700d9e@web.de> (raw)
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 <jltobler@gmail.com>
> Signed-off-by: Toon Claes <toon@iotcl.com>
> ---
>  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é


  reply	other threads:[~2025-08-07 19:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04 16:56 [PATCH 0/4] Fix archiving some corner-case files into zip Toon Claes
2025-08-04 16:56 ` [PATCH 1/4] archive-zip: deduplicate code setting output buffer in write_zip_entry() Toon Claes
2025-08-07 19:51   ` René Scharfe
2025-08-04 16:56 ` [PATCH 2/4] archive-zip: remove unneccesarry condition " Toon Claes
2025-08-07 19:51   ` René Scharfe [this message]
2025-08-04 16:56 ` [PATCH 3/4] archive-zip: in write_zip_entry() call git_deflate() in a loop Toon Claes
2025-08-07 19:51   ` René Scharfe
2025-08-04 16:56 ` [PATCH 4/4] archive-zip: move git_deflate() with Z_FINISH into the loop Toon Claes
2025-08-07 19:51   ` René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7650da07-dd89-4e79-ac81-1c99f4700d9e@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=jltobler@gmail.com \
    --cc=toon@iotcl.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).