]> git.proxmox.com Git - mirror_iproute2.git/commit
json_print: Fix hidden 64-bit type promotion
authorToke Høiland-Jørgensen <toke@toke.dk>
Wed, 25 Apr 2018 15:28:57 +0000 (17:28 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 25 Apr 2018 18:08:55 +0000 (11:08 -0700)
commit4db2ff0db46f6368d89cfb3498a700e1256d2a04
treedc4f9bec798544f96757a9002dac2971fb36c7ab
parentbf717756b50dc96b27d66c5247a5d543c5f75168
json_print: Fix hidden 64-bit type promotion

print_uint() will silently promote its variable type to uint64_t, but there
is nothing that ensures that the format string specifier passed along with
it fits (and the function name suggest to pass "%u").

Fix this by changing print_uint() to use a native 'unsigned int' type, and
introduce a separate print_u64() function for printing 64-bit values. All
call sites that were actually printing 64-bit values using print_uint() are
converted to use print_u64() instead.

Since print_int() was already using native int types, just add a
print_s64() to match, but don't convert any call sites. For symmetry,
also add a print_luint() method (with no users).

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
include/json_print.h
include/json_writer.h
ip/ipaddress.c
ip/ipmacsec.c
ip/ipmroute.c
ip/ipntable.c
ip/iproute_lwtunnel.c
ip/iptuntap.c
ip/tcp_metrics.c
lib/json_print.c
lib/json_writer.c