Re: [PATCH v2 15/17] midx: use 64-bit multiplication for chunk sizes
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 8, 2021, 05:41 UTC
- Message-ID
- <xmqqczxb6rq3.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20210207195053.GA1016223@szeder.dev>
SZEDER Gábor <szeder.dev@gmail.com> writes:
Show 6 quoted lines
> No, that patch also removes lines like: > > - chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + ctx.entries_nr * the_hash_algo->rawsz; > > - chunk_offsets[cur_chunk] = chunk_offsets[cur_chunk - 1] + > - ctx.num_large_offsets * MIDX_CHUNK_LARGE_OFFSET_WIDTH;
OK. In other words, the above was replaced in the same patch with
add_chunk(...., U32 * U32);
where the called function expects the result of the multiplication as size_t in its function prototype. It is a bit sad that U32*U32 to compute the argument that is to be passed as U64 must be casted as (uint64_t)U32*U32 by the caller X-<.
The original that the above replaced, shown in your quote, is:
U64 = U64 + U32 * U32;
I also wish that the fact that it is added to U64 is sufficient not to require the RHS to be written as U64 + (uint64_t) U32 * U32 (in other words, the original that was removed was OK without cast).
Sad.