From 573e9a3310ec99c34cee8a45a860ae353ac5994c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 10 Jul 2019 10:30:12 +0200 Subject: [PATCH] networkd: silence bogus gcc warning about %s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #12931. In file included from ../src/basic/macro.h:558, from ../src/basic/alloc-util.h:9, from ../src/network/networkd-link.c:7: ../src/network/networkd-link.c: In function ‘link_sysctl_ipv6_enabled’: ../src/basic/log.h:107:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=] 107 | log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../src/shared/log-link.h:21:25: note: in expansion of macro ‘log_internal’ 21 | log_internal(level, error, _FILE_, __LINE__, __func__, ##__VA_ARGS__); \ | ^~~~~~~~~~~~ ../src/shared/log-link.h:33:50: note: in expansion of macro ‘log_link_full’ 33 | #define log_link_warning_errno(link, error, ...) log_link_full(link, LOG_WARNING, error, ##__VA_ARGS__) | ^~~~~~~~~~~~~ ../src/network/networkd-link.c:83:24: note: in expansion of macro ‘log_link_warning_errno’ 83 | return log_link_warning_errno(link, r, | ^~~~~~~~~~~~~~~~~~~~~~ ../src/network/networkd-link.c:84:77: note: format string is defined here 84 | "Failed to read net.ipv6.conf.%s.disable_ipv6 sysctl property: %m", | ^~ cc1: some warnings being treated as errors --- src/network/networkd-link.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 5f91d66dc09..f45d881cf8d 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -78,11 +78,12 @@ int link_sysctl_ipv6_enabled(Link *link) { if (link->sysctl_ipv6_enabled >= 0) return link->sysctl_ipv6_enabled; - r = sysctl_read_ip_property(AF_INET6, link->ifname, "disable_ipv6", &value); + const char *ifname = link->ifname; /* work around bogus gcc warning */ + r = sysctl_read_ip_property(AF_INET6, ifname, "disable_ipv6", &value); if (r < 0) return log_link_warning_errno(link, r, "Failed to read net.ipv6.conf.%s.disable_ipv6 sysctl property: %m", - link->ifname); + ifname); link->sysctl_ipv6_enabled = value[0] == '0'; return link->sysctl_ipv6_enabled;