Re: [PATCH 1/2] archive: replace write_or_die() calls with write_block_or_die()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Apr 26, 2019, 14:29 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1904261028220.45@tvgsbejvaqbjf.bet>
- In-Reply-To
- <xmqqzhouwizg.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Sat, 13 Apr 2019, Junio C Hamano wrote:
Show 16 quoted lines
> Jeff King <peff@peff.net> writes:
>
> >> +/* writes out the whole block, or dies if fails */
> >> +static void write_block_or_die(const char *block) {
> >> + if (gzip) {
> >> + if (gzwrite(gzip, block, (unsigned) BLOCKSIZE) != BLOCKSIZE)
> >> + die(_("gzwrite failed"));
> >> + } else {
> >> + write_or_die(1, block, BLOCKSIZE);
> >> + }
> >> +}
>
> I agree everything you said you your two review messages.
>
> One thing you did not mention but I found disturbing was that this
> does not take size argument but hardcodes BLOCKSIZE.That is very much on purpose, as this code really is specific to the `tar` file format, which has a fixed, well-defined block size. It would make it easier to introduce a bug if that was a parameter.
Ciao, Dscho