reftable/basics: adjust hash_size()
to return uint32_t
The `hash_size()` function returns the number of bytes used by the hash function. Weirdly enough though, it returns a signed integer for its size even though the size obviously cannot ever be negative. The only case where it could be negative is if the function returned an error when asked for an unknown hash, but we assert(3p) instead. Adjust the type of `hash_size()` to be `uint32_t` and adapt all places that use signed integers for the hash size to follow suit. This also allows us to get rid of a couple asserts that we had which verified that the size was indeed positive, which further stresses the point that this refactoring makes sense. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5ac65f0d6b
commit
57adf71b93
@ -272,7 +272,7 @@ size_t common_prefix_size(struct reftable_buf *a, struct reftable_buf *b)
|
||||
return p;
|
||||
}
|
||||
|
||||
int hash_size(enum reftable_hash id)
|
||||
uint32_t hash_size(enum reftable_hash id)
|
||||
{
|
||||
if (!id)
|
||||
return REFTABLE_HASH_SIZE_SHA1;
|
||||
|
Reference in New Issue
Block a user