lists.arthurdejong.org
RSS feed

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



On Wed, 11 Mar 2015, Lukas Slebodnik wrote:

| 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.

Only if you do not care about portability.
Some platforms do not have the z modifier.

| @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
| 

-- 
Tim Rice                                Multitalents
tim@multitalents.net


-- 
To unsubscribe send an email to
nss-pam-ldapd-users-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-users/