From: Junio C Hamano Date: Fri, 10 Nov 2023 23:38:54 GMT Subject: Re: [PATCH 1/7] chunk-format: introduce `pair_chunk_expect()` helper Message-ID: In-Reply-To: Taylor Blau writes: > But I don't think we enjoy the same benefits in the MIDX scenario. In > this case, the num_objects field is just: > > m->num_objects = ntohl(m->chunk_oid_fanout[255]) > > so I don't think we can make the same guarantees about what is and isn't > save to compute under size_t arithmetic. So ..., from the correctness's point of view, if we do not mind st_mult() dying, the "multiply-and-compare" should give us much more robust results. If we do mind st_mult() dying, we could pair the "truncating-division-and-compare" you wrote with "ensure that chunk size is a multiple of record size" to achieve the same, I would think. I.e., if (chunk_size % pcd->record_size || chunk_size / pcd->record_size != pcd->record_nr) return -1; or something like that.