From 66a6bd68976a20449bfcae0c55853d497a3f9b27 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 13 Nov 2015 12:30:57 +0100 Subject: networkd: fix a couple of format string types We really should use %i for ints, and %u for unsigneds, and be careful what we pick depending on the type we want to print. --- src/network/networkd-link.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/network') diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 07910c2c3b..a1401cc33f 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -1901,11 +1901,11 @@ static int link_set_ipv6_privacy_extensions(Link *link) { return 0; s = link_ipv6_privacy_extensions(link); - if (s == _IPV6_PRIVACY_EXTENSIONS_INVALID) + if (s < 0) return 0; p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/use_tempaddr"); - xsprintf(buf, "%u", link->network->ipv6_privacy_extensions); + xsprintf(buf, "%u", (unsigned) link->network->ipv6_privacy_extensions); r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE); if (r < 0) @@ -1927,7 +1927,7 @@ static int link_set_ipv6_accept_ra(Link *link) { p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/accept_ra"); - /* we handle router advertisments ourselves, tell the kernel to GTFO */ + /* We handle router advertisments ourselves, tell the kernel to GTFO */ r = write_string_file(p, "0", WRITE_STRING_FILE_VERIFY_ON_FAILURE); if (r < 0) log_link_warning_errno(link, r, "Cannot disable kernel IPv6 accept_ra for interface: %m"); @@ -1936,7 +1936,7 @@ static int link_set_ipv6_accept_ra(Link *link) { } static int link_set_ipv6_dad_transmits(Link *link) { - char buf[DECIMAL_STR_MAX(unsigned) + 1]; + char buf[DECIMAL_STR_MAX(int) + 1]; const char *p = NULL; int r; @@ -1951,8 +1951,7 @@ static int link_set_ipv6_dad_transmits(Link *link) { return 0; p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/dad_transmits"); - - xsprintf(buf, "%u", link->network->ipv6_dad_transmits); + xsprintf(buf, "%i", link->network->ipv6_dad_transmits); r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE); if (r < 0) @@ -1962,7 +1961,7 @@ static int link_set_ipv6_dad_transmits(Link *link) { } static int link_set_ipv6_hop_limit(Link *link) { - char buf[DECIMAL_STR_MAX(unsigned) + 1]; + char buf[DECIMAL_STR_MAX(int) + 1]; const char *p = NULL; int r; @@ -1977,8 +1976,7 @@ static int link_set_ipv6_hop_limit(Link *link) { return 0; p = strjoina("/proc/sys/net/ipv6/conf/", link->ifname, "/hop_limit"); - - xsprintf(buf, "%u", link->network->ipv6_hop_limit); + xsprintf(buf, "%i", link->network->ipv6_hop_limit); r = write_string_file(p, buf, WRITE_STRING_FILE_VERIFY_ON_FAILURE); if (r < 0) -- cgit v1.2.3-54-g00ecf