On 17.02.2008 05:02, Peter Stuge wrote:
> On Sun, Feb 17, 2008 at 12:34:24AM +0100, Carl-Daniel Hailfinger wrote:
>   
>> +enum compalgo {
>> +    none = 0,
>> +    lzma = 1,
>> +    nrv2b = 2,
>> +    zeroes = 3,
>> +    /* invalid should always be the last entry. */
>> +    invalid
>> +};
>>     
>
> It's fairly common to uppercase these. Do we want that too?
>   

This was just a straight copy from util/lar, but I agree. We use these 
enums like #defines, so uppercasing seems indeed the best way to bring 
this hint to the developer.

>> +    const char *algoname = algo_name[(archive->compression >= invalid)
>> +                                    ? invalid : archive->compression];
>>     
>
> Not sure about invalid. I would be less worried if invalid was set to
> some explicit value, e.g. -1.

We use archive->compression as array index. The line above is there to 
make sure we do not dereference a random pointer outside the array. That 
also rules out a negative value for invalid because accessing arrays 
with negative indices is real scary EVIL.

> The current proposal means we can never remove algorithms.
>   

How so? We have to keep the number reserved if we ever abandon a 
compression algorithm, but that's it.

Regards,
Carl-Daniel

-- 
http://www.hailfinger.org/


-- 
coreboot mailing list
[email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to