diff options
author | Коренберг Марк (дома) <socketpair@gmail.com> | 2012-08-29 17:59:17 (GMT) |
---|---|---|
committer | Коренберг Марк (дома) <socketpair@gmail.com> | 2012-08-29 21:19:04 (GMT) |
commit | ab15d06d13484df246eb0fbd9ab6a6012ed81153 (patch) | |
tree | 46ca57bdb8f7f31cbad6119e7ef33c74d9d54c00 /src | |
parent | 582a32433ca03dd2ca78dc485329cb81d391a192 (diff) | |
download | libnl-ab15d06d13484df246eb0fbd9ab6a6012ed81153.zip libnl-ab15d06d13484df246eb0fbd9ab6a6012ed81153.tar.gz libnl-ab15d06d13484df246eb0fbd9ab6a6012ed81153.tar.bz2 |
"%llu" replaced with "%" PRIu64
On some architectures, uint64_t is defined as:
typedef unsigned long long int __u64;
on another architectures as:
typedef unsigned long int __u64;
So, according to man 3 printf,
uint64_t should be printed as "%llu" on some architectures, and as "%lu" on another. The same for scanf.
To eliminate that challenge, there is inttypes.h, in which appropriate constants
are defined for current architecture.
32-bit types (and even 16 and 8 bit types) should be printed using such constants if
printed variable defined as uint_XXXt or intXXXt type. But in reality 32-bit and less
types does not gain run-time error (except in scanf), because they pushed to stack as
32-bit values at least. So, I decide not to fix that.
Diffstat (limited to 'src')
-rw-r--r-- | src/nl-list-sockets.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nl-list-sockets.c b/src/nl-list-sockets.c index 868006e..c2fa1cd 100644 --- a/src/nl-list-sockets.c +++ b/src/nl-list-sockets.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) while (fgets(buf, sizeof(buf), fd)) { unsigned long sk, cb; int ret, proto, pid, rmem, wmem, refcnt; - uint32_t groups; + unsigned int groups; ret = sscanf(buf, "%lx %d %d %08x %d %d %lx %d\n", &sk, &proto, &pid, &groups, &rmem, &wmem, |