[SSSD] [PATCH] Add support for explicit 32/64 bit numbers
Jakub Hrozek
jhrozek at redhat.com
Tue Apr 13 15:40:00 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 04/13/2010 04:39 PM, Dmitri Pal wrote:
> Jakub Hrozek wrote:
>> On 04/12/2010 05:13 PM, Dmitri Pal wrote:
>>> Hello
>>
>>> The attached patch adds 4 conversion functions capable
>>> of handling the following types of the values:
>>> int32_t, int64_t, uint32_t and uint64_t
>>
>>
>> Ack to the code, but there is one thing to fix in the unit test:
>> the %lld format specifier for int64_t is correct on 32bit architectures
>> only, on 64bit the correct specifier is %ld - so the code emits a
>> compiler warning on 64bit.
>>
>> Martin suggested that the values should be always casted up to long long
>> - it will have some performance penalty, but since this is tracing code
>> only, it doesn't matter. If we ever need to print exact-sized values in
>> production code, we can use the C99 set of PRId64/PRId32 macros.
>
> Can you post the warning?
> I do not understand what line generates it.
> All macros have explicit type cast.
> There should not be a warning.
> May be I am using signed when it should be unsigned? Then it should be a
> bug...
>
The warnings are as follows:
- -----
ini_config_ut.c: In function ‘get_test’:
ini_config_ut.c:1169: warning: format ‘%lld’ expects type ‘long long
int’, but argument 2 has type ‘int64_t’
ini_config_ut.c:1203: warning: format ‘%llu’ expects type ‘long long
unsigned int’, but argument 2 has type ‘uint64_t’
- -----
You will not see them on your 32bit system as the formatting string is
correct for a 32bit system, it is not for a 64bit one, where a '%ld'
would be correct.
Either casting the value "long long" or "unsigned long long" or using
the C99 PRI macros would solve the issue.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvEkFAACgkQHsardTLnvCWkWQCeJf9qj24eAS6BfVICoZ2Xkp0t
roEAoJ2mofwX0qLSu9OkLYv91g+1bRv3
=/npj
-----END PGP SIGNATURE-----
More information about the sssd-devel
mailing list