Re: [PATCH 1/3] packfile: factor out --pack_header argument parsing
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 17, 2025, 22:45 UTC
- Message-ID
- <xmqqo705hxfz.fsf@gitster.g>
- In-Reply-To
- <20250117125459.GA2893666@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 7 quoted lines
> } else if (starts_with(arg, "--pack_header=")) {
> - struct pack_header *hdr;
> - char *c;
> -
> - hdr = (struct pack_header *)input_buffer;
> - hdr->hdr_signature = htonl(PACK_SIGNATURE);
> - hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));Interesting. So the file-scope static input_buffer[] sits in the BSS and happens to be well aligned not to cause the problem, but ...
Show 10 quoted lines
> @@ -645,18 +646,9 @@ int cmd_unpack_objects(int argc,
> continue;
> }
> if (starts_with(arg, "--pack_header=")) {
> - struct pack_header *hdr;
> - char *c;
> -
> - hdr = (struct pack_header *)buffer;
> - hdr->hdr_signature = htonl(PACK_SIGNATURE);
> - hdr->hdr_version = htonl(strtoul(arg + 14, &c, 10));... the same file-scope static buffer[] that also sits in the BSS was not well aligned by chance?
Otherwise these should be identical code. Very interesting.
And of course the fix in the [2/3] is absolutely the right thing to do.
Thanks.