[patch v3] PS3: Fix printing of os-area magic numbers

Geoff Levand geoffrey.levand at am.sony.com
Mon Dec 24 04:20:15 EST 2007


On 12/23/2007 01:51 AM, Geert Uytterhoeven wrote:
> On Sat, 22 Dec 2007, Geoff Levand wrote:
>> +static void dump_field(char *s, const u8 *f, unsigned int size)
>> +{
>> +#if defined(DEBUG)
>> +	unsigned int i;
>> +
>> +	for (i = 0; i < size; i++)
>> +		s[i] = isprint(f[i]) ? f[i] : '.';
>> +	s[i] = 0;
>> +#endif
>> +}
> 
> Sorry for nitpicking again.
> 
> Usually the _length_ of a C-string is the number of characters, while the
> _size_ of a C-string includes the zero-terminator.
> 
> In dump_field() it writes size+1 bytes to s.

The arg size is the size of the field in bytes:

  dump_field(str, h->magic_num, sizeof(h->magic_num));

To me, the name length doesn't seem to convey that.

-Geoff




More information about the Linuxppc-dev mailing list