From: Junio C Hamano Date: Thu, 19 Mar 2026 16:08:44 GMT Subject: Re: [PATCH 01/14] oidtree: modernize the code a bit Message-ID: In-Reply-To: <20260319-b4-pks-odb-source-abbrev-v1-1-5ddebad292b0@pks.im> Patrick Steinhardt writes: > +void oidtree_each(struct oidtree *ot, const struct object_id *prefix, > + size_t prefix_hex_len, oidtree_each_cb cb, void *cb_data) > { > - size_t klen = oidhexsz / 2; > - struct oidtree_iter_data x = { 0 }; > - assert(oidhexsz <= GIT_MAX_HEXSZ); > - > - x.fn = fn; > - x.arg = arg; > - x.algo = oid->algo; > - if (oidhexsz & 1) { > - x.last_byte = oid->hash[klen]; > - x.last_nibble_at = &klen; > + struct oidtree_each_data data = { > + .cb = cb, > + .cb_data = cb_data, > + .algo = prefix->algo, > + }; > + size_t klen = prefix_hex_len / 2; > + assert(prefix_hex_len <= GIT_MAX_HEXSZ); I know the original also used GIT_MAX_HEXSZ to clamp the length for sanity, but because we know what algorithm is in use, I wonder if we want to use the limit more specific to it.