Re: [PATCH] warnings cleanup: size_t should be formatted %lu rather than %d
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
Re: [PATCH] warnings cleanup: size_t should be formatted %lu rather than %d
- From: Lukas Slebodnik <lslebodn [at] redhat.com>
- To: Patrick McLean <chutzpah [at] gentoo.org>
- Cc: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: Re: [PATCH] warnings cleanup: size_t should be formatted %lu rather than %d
- Date: Wed, 11 Mar 2015 19:12:10 +0100
On (11/03/15 10:55), Patrick McLean wrote:
>In several places the code uses a %d format to print a size_t variable.
>On amd64 at least size_t is an unsigned long, so use %lu instead.
That's not good approach. The size differs on 32-bit platforms (ix86)
You should use "%zd" for size_t variable
and "%zu" for ssize_t variable.
@see man 3 printf -> The length modifier
But IIRC the most important part is "z" modifier and warning is not printed
if number is unsigned or not ("d" or "u"). So you can use either "%zd" or "%zu"
for size_t and ssize_t variables
LS
--
To unsubscribe send an email to
nss-pam-ldapd-users-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-users/