1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 16:59:03 +03:00

networkd: silence bogus gcc warning about %s

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
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-07-10 10:30:12 +02:00
parent 706fb34851
commit 573e9a3310

View File

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