Re: [RFC PATCH] build: avoid %zu in translated strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/18/2010 03:04 AM, Daniel P. Berrange wrote:
> 
> I find the PRI* stuff rather fugly. Can't we just use %llu and
> cast to (unsigned long long)

Unfortunately, %llu is equally non-portable to mingw.  And yes, we also
have some %llu encoded into translated strings, which would also need help.

> 
> The question of printf-posix license doesn't appear relevant since
> remoteError & friends all use asprintf() which is LGPLv2+ already.

We use the 'vasprintf' module, which is indeed LGPLv2+, but it does not
guarantee the existence of %llu nor %zu -- it only guarantees that you
have the [v]asprintf wrappers around your current system's
(non-)compliant printf family, so it inherits the same bugs regarding
unsupported specifiers.  We would have to use the vasprintf-posix module
to get %zu, but that module is LGPLv3+.

One other potential solution: most (all?) of our translated strings
involve error messages, and are therefore already funneled through our
virterror.c implementation.  As long as a string containing %zu or %llu
is never directly handed to printf, but is guaranteed to go through
virterror.c, then it would be possible to have virterror.c do some
#ifdef magic such that on all sane platforms, the %zu and %llu are used
unchanged (no extra overhead required); but on broken platforms (aka
mingw), %zu and %llu are translated at runtime to %lu or %I64u (the %zu
translation depends on whether you are 32-bit/64-bit mingw, and the
64-bit translation relies on microsoft's non-standard format specifier).
 This solution would then confine the ugliness to one file, such that
the rest of libvirt can use %zu and %llu at will.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]