mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
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
@@ -30,7 +30,7 @@ struct block_writer {
|
||||
|
||||
/* How often to restart keys. */
|
||||
uint16_t restart_interval;
|
||||
int hash_size;
|
||||
uint32_t hash_size;
|
||||
|
||||
/* Offset of next uint8_t to write. */
|
||||
uint32_t next;
|
||||
@@ -48,7 +48,7 @@ struct block_writer {
|
||||
* initializes the blockwriter to write `typ` entries, using `block` as temporary
|
||||
* storage. `block` is not owned by the block_writer. */
|
||||
int block_writer_init(struct block_writer *bw, uint8_t typ, uint8_t *block,
|
||||
uint32_t block_size, uint32_t header_off, int hash_size);
|
||||
uint32_t block_size, uint32_t header_off, uint32_t hash_size);
|
||||
|
||||
/* returns the block type (eg. 'r' for ref records. */
|
||||
uint8_t block_writer_type(struct block_writer *bw);
|
||||
@@ -72,7 +72,7 @@ struct block_reader {
|
||||
|
||||
/* the memory block */
|
||||
struct reftable_block block;
|
||||
int hash_size;
|
||||
uint32_t hash_size;
|
||||
|
||||
/* Uncompressed data for log entries. */
|
||||
z_stream *zstream;
|
||||
@@ -92,7 +92,7 @@ struct block_reader {
|
||||
/* initializes a block reader. */
|
||||
int block_reader_init(struct block_reader *br, struct reftable_block *bl,
|
||||
uint32_t header_off, uint32_t table_block_size,
|
||||
int hash_size);
|
||||
uint32_t hash_size);
|
||||
|
||||
void block_reader_release(struct block_reader *br);
|
||||
|
||||
@@ -108,7 +108,7 @@ struct block_iter {
|
||||
uint32_t next_off;
|
||||
const unsigned char *block;
|
||||
size_t block_len;
|
||||
int hash_size;
|
||||
uint32_t hash_size;
|
||||
|
||||
/* key for last entry we read. */
|
||||
struct reftable_buf last_key;
|
||||
|
||||
Reference in New Issue
Block a user