[ipxe-devel] %lld format patch
Michael Brown
mcb30 at ipxe.org
Fri Nov 6 12:36:35 UTC 2015
On 04/11/15 09:35, James Harper wrote:
>> vsprintf.c currently deliberately omits support for %lld in order to
>> avoid needing to drag in the support for 64-bit divisions. I note that
>> there is (my) code in time.c, ocsp.c and x509.c which erroneou uses
>> %lld in debug messages to display seconds since the Epoch.
>
> Ah. I assumed that because %llx was in there, %lld would also work, and noted that %lld was used by a bunch of DBG statements. %llx presumably shifts rather than divides though.
Yes, %llx just shifts.
>> I would be tempted to amend these debug messages to use %#llx, rather
>> than adding either incomplete or partial support for %lld, but I'm open
>> to argument here. What's your use case for %lld?
>
> I am sending the lba as a text string (part of the path retrieved by tftp)
Is this for your custom SAN protocol? If that's the only use case, then
I'm tempted to propose that you send %#llx from iPXE and change the
server side to use strtoull() or equivalent, which would then accept
either decimal or hex.
>> Even with this patch, the upper 32 bits (on a 32-bit platform) will be
>> discarded when passed to format_decimal().
>
> What is a 32 bit platform in this context? Will it only fail to work if the CPU itself is incapable of 64 bit mode?
The value gets cast to a signed long when it is passed to
format_decimal(). For a 32-bit built (i.e. a BIOS build), this will
truncate the value to 32 bits.
Michael
More information about the ipxe-devel
mailing list