Subject: Re: [PATCH 4/8] add functions for memory-efficient bitmaps

From: Torsten Bögershausen <[email-masked]>
Date: Thu, 26 Jun 2014 05:15:05 +0200

On 2014-06-26 01.40, Jeff King wrote:
[]

> + */
> +static inline int bitset_sizeof(int num_bits)
> +{
> +	return (num_bits + CHAR_BIT - 1) / CHAR_BIT;
> +}
Just a general question about the usage of "int" here (and at other places):
Is there a special reason for new code to allow num_bits to be negative ?

To my knowledge all the size_t definitions these days are positive,
because a size can not be negative.

As a reader of the code I always wonder if there is a special meaning with
negative values, (as the result of read() to indicate an error) but there isn't.

Should we use
"unsigned" here ?
or "unsigned int" ?
or "size_t" (Which may use 64 bits, which feels like a overkill)