From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48411 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OJv4Q-0007up-RR for qemu-devel@nongnu.org; Wed, 02 Jun 2010 17:01:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OJv4P-0001T4-2u for qemu-devel@nongnu.org; Wed, 02 Jun 2010 17:01:50 -0400 Received: from mail.gmx.net ([213.165.64.20]:55788) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OJv4O-0001Sl-LM for qemu-devel@nongnu.org; Wed, 02 Jun 2010 17:01:49 -0400 Message-ID: From: "Sebastian Herbszt" References: <4BFFE03F.40606@redhat.com> <915D11B7A1EA4FDC80761D20504E920B@FSCPC> <4C05FDDA.7040107@redhat.com> In-Reply-To: <4C05FDDA.7040107@redhat.com> Date: Wed, 2 Jun 2010 23:01:17 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [SeaBIOS] SMBIOS strings List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: seabios@seabios.org, QEMU Developers 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