[SeaBIOS] SMBIOS strings

Sebastian Herbszt herbszt at gmx.de
Wed Jun 2 23:01:17 CEST 2010


Jes Sorensen wrote:
> On 06/01/10 22:26, Sebastian Herbszt wrote:
>> Jes Sorensen wrote:
>>> Handle 0x0401, DMI type 4, 32 bytes
>>> Processor Information
>>> -       Socket Designation: CPU 1
>>> +       Socket Designation: CPU01
>> 
>> smbios.c got
>> snprintf((char*)start, 6, "CPU%2x", cpu_number);
>> 
>> It should print "CPU 1" instead of "CPU01" because the
>> padding should be done with spaces not zeros. Maybe
>> bvprintf() doesn't handle it correctly?
> 
> I looked at the man page for snprintf() and it isn't clear to me that it
> is required to space pad when printing hex numbers.

"The flag characters

...

0

The value should be zero padded. For d, i, o, u, x, X, a, A, e, E, f, F, g,
and G conversions, the converted value is padded on the left with zeros rather
than blanks. If the 0 and - flags both appear, the 0 flag is ignored. If a
precision is given with a numeric conversion (d, i, o, u, x, and X), the 0 flag
is ignored. For other conversions, the behavior is undefined." [1]

So without "0" flag it should be space padded.

> Having looked at the other pieces, I think this is probably the only one
> we might want to change. It should be pretty easy to just do something like:
> 
> if (cpu_number < 0x10)
> snprintf("CPU %x", cpu_number);
> else
> snprintf("CPU%2x", cpu_number);
> 
> Esthetically I think this would be prettier, but question is whether
> it's something to worry about or not.

Either change it here or fix bvprintf().

Also "CPU a" looks a bit weird. Maybe change it to "CPU A" (upper case letter) ?

> Cheers,
> Jes

[1] http://linux.die.net/man/3/printf

Sebastian




More information about the SeaBIOS mailing list