Re: [PATCH 4/8] add functions for memory-efficient bitmaps
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Jun 26, 2014, 03:15 UTC
- Message-ID
- <53AB9039.8040809@web.de>
- In-Reply-To
- <20140625234000.GD23146@sigill.intra.peff.net>
On 2014-06-26 01.40, Jeff King wrote: []
Show 5 quoted lines
> + */
> +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)