Systemd: Compilation warnings/errors with GCC 10

Created on 29 Jan 2020  ·  1Comment  ·  Source: systemd/systemd

systemd version the issue has been seen with

latest master


Used distribution

Fedora Rawhide with gcc-10.0.1-0.5.fc32.x86_64

Following warnings/errors may not be related strictly to GCC 10, but that's where I stumbled upon them when debugging #14677.

-O2

[320/1551] Compiling C object 'src/shared/5afaae1@@systemd-shared-244@sta/ethtool-util.c.o'.
../src/shared/ethtool-util.c: In function ‘ethtool_get_permanent_macaddr’:
../src/shared/ethtool-util.c:258:60: warning: array subscript 5 is outside the bounds of an interior zero-length array ‘__u8[0]’ {aka ‘unsigned char[0]’} [-Wzero-length-bounds]
  258 |                 ret->ether_addr_octet[i] = epaddr.addr.data[i];
      |                                            ~~~~~~~~~~~~~~~~^~~
In file included from ../src/shared/ethtool-util.c:5:
../src/shared/linux/ethtool.h:704:7: note: while referencing ‘data’
  704 |  __u8 data[0];
      |       ^~~~
../src/shared/ethtool-util.c: In function ‘ethtool_set_features’:
../src/shared/ethtool-util.c:480:31: warning: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[0]’} [-Wzero-length-bounds]
  480 |         len = buffer.info.data[0];
      |               ~~~~~~~~~~~~~~~~^~~
In file included from ../src/shared/ethtool-util.c:5:
../src/shared/linux/ethtool.h:631:8: note: while referencing ‘data’
  631 |  __u32 data[0];
      |        ^~~~
[379/1551] Compiling C object 'src/shared/5afaae1@@systemd-shared-244@sta/utmp-wtmp.c.o'.
../src/shared/utmp-wtmp.c: In function ‘init_entry’:
../src/shared/utmp-wtmp.c:101:17: warning: ‘strncpy’ offset [195, 255] from the object at ‘uts’ is out of the bounds of referenced subobject ‘release’ with type ‘char[65]’ at offset 130 [-Warray-bounds]
  101 |                 strncpy(store->ut_host, uts.release, sizeof(store->ut_host));
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../src/shared/utmp-wtmp.c:10:
/usr/include/sys/utsname.h:57:10: note: subobject ‘release’ declared here
   57 |     char release[_UTSNAME_RELEASE_LENGTH];
      |          ^~~~~~~
[494/1551] Compiling C object 'src/network/70b1c79@@networkd-core@sta/netdev_tunnel.c.o'.
../src/network/netdev/tunnel.c: In function ‘ipip_sit_init’:
../src/network/netdev/tunnel.c:732:27: warning: implicit conversion from ‘enum <anonymous>’ to ‘FooOverUDPEncapType’ [-Wenum-conversion]
  732 |         t->fou_encap_type = FOU_ENCAP_DIRECT;
      |                           ^
../src/network/netdev/tunnel.c: In function ‘gre_erspan_init’:
../src/network/netdev/tunnel.c:774:27: warning: implicit conversion from ‘enum <anonymous>’ to ‘FooOverUDPEncapType’ [-Wenum-conversion]
  774 |         t->fou_encap_type = FOU_ENCAP_DIRECT;
      |                           ^
In file included from ../src/basic/macro.h:586,
                 from ../src/basic/alloc-util.h:9,
                 from ../src/shared/conf-parser.h:10,
                 from ../src/network/networkd-dhcp-server.h:4,
                 from ../src/network/networkd-dhcp-server.c:5:
In function ‘link_push_uplink_dns_to_dhcp_server’,
    inlined from ‘dhcp4_server_configure’ at ../src/network/networkd-dhcp-server.c:242:37:
../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, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
      |                         ^~~~~~~~~~~~
../src/shared/log-link.h:24:37: note: in expansion of macro ‘log_link_full’
   24 | #define log_link_debug(link, ...)   log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
      |                                     ^~~~~~~~~~~~~
../src/network/networkd-dhcp-server.c:48:9: note: in expansion of macro ‘log_link_debug’
   48 |         log_link_debug(link, "Copying DNS server information from %s", link->ifname);
      |         ^~~~~~~~~~~~~~
../src/network/networkd-dhcp-server.c: In function ‘dhcp4_server_configure’:
../src/network/networkd-dhcp-server.c:48:67: note: format string is defined here
   48 |         log_link_debug(link, "Copying DNS server information from %s", link->ifname);
      |                                                                   ^~
In file included from ../src/basic/macro.h:586,
                 from ../src/basic/alloc-util.h:9,
                 from ../src/shared/conf-parser.h:10,
                 from ../src/network/networkd-dhcp-server.h:4,
                 from ../src/network/networkd-dhcp-server.c:5:
In function ‘link_push_uplink_ntp_to_dhcp_server’,
    inlined from ‘dhcp4_server_configure’ at ../src/network/networkd-dhcp-server.c:259:37:
../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, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
      |                         ^~~~~~~~~~~~
../src/shared/log-link.h:24:37: note: in expansion of macro ‘log_link_full’
   24 | #define log_link_debug(link, ...)   log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
      |                                     ^~~~~~~~~~~~~
../src/network/networkd-dhcp-server.c:102:9: note: in expansion of macro ‘log_link_debug’
  102 |         log_link_debug(link, "Copying NTP server information from %s", link->ifname);
      |         ^~~~~~~~~~~~~~
../src/network/networkd-dhcp-server.c: In function ‘dhcp4_server_configure’:
../src/network/networkd-dhcp-server.c:102:67: note: format string is defined here
  102 |         log_link_debug(link, "Copying NTP server information from %s", link->ifname);
      |                                                                   ^~
In file included from ../src/basic/macro.h:586,
                 from ../src/basic/alloc-util.h:9,
                 from ../src/shared/conf-parser.h:10,
                 from ../src/network/networkd-dhcp-server.h:4,
                 from ../src/network/networkd-dhcp-server.c:5:
In function ‘link_push_uplink_sip_to_dhcp_server’,
    inlined from ‘dhcp4_server_configure’ at ../src/network/networkd-dhcp-server.c:277:37:
../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, PROJECT_FILE, __LINE__, __func__, ##__VA_ARGS__); \
      |                         ^~~~~~~~~~~~
../src/shared/log-link.h:24:37: note: in expansion of macro ‘log_link_full’
   24 | #define log_link_debug(link, ...)   log_link_full(link, LOG_DEBUG, 0, ##__VA_ARGS__)
      |                                     ^~~~~~~~~~~~~
../src/network/networkd-dhcp-server.c:151:9: note: in expansion of macro ‘log_link_debug’
  151 |         log_link_debug(link, "Copying SIP server information from %s", link->ifname);
      |         ^~~~~~~~~~~~~~
../src/network/networkd-dhcp-server.c: In function ‘dhcp4_server_configure’:
../src/network/networkd-dhcp-server.c:151:67: note: format string is defined here
  151 |         log_link_debug(link, "Copying SIP server information from %s", link->ifname);
      |                                                                   ^~
cc1: some warnings being treated as errors

-O3

(first %s argument here)

../src/core/path.c: In function ‘path_serialize’:
../src/core/path.c:616:24: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  616 |                 (void) serialize_item_format(f, "path-spec", "%s %i %s",
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  617 |                                              path_type_to_string(s->type),
      |                                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  618 |                                              s->previous_exists,
      |                                              ~~~~~~~~~~~~~~~~~~~
  619 |                                              s->path);
      |                                              ~~~~~~~~

(second %s argument here)

In function ‘path_spec_dump’,
    inlined from ‘path_dump’ at ../src/core/path.c:392:17:
../src/core/path.c:226:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  226 |         fprintf(f,
      |         ^~~~~~~~~~
  227 |                 "%s%s: %s\n",
      |                 ~~~~~~~~~~~~~
  228 |                 prefix,
      |                 ~~~~~~~
  229 |                 path_type_to_string(s->type),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  230 |                 s->path);
      |                 ~~~~~~~~
cc1: some warnings being treated as errors
[422/1551] Compiling C object 'src/core/2ac6ece@@core@sta/manager.c.o'.
In function ‘manager_load_unit_prepare’,
    inlined from ‘manager_load_unit’ at ../src/core/manager.c:2027:13,
    inlined from ‘manager_add_job_by_name’ at ../src/core/manager.c:1810:13:
../src/core/manager.c:1971:24: warning: argument 1 null where non-null expected [-Wnonnull]
 1971 |                 name = basename(path);
      |                        ^~~~~~~~~~~~~~
In file included from ../src/systemd/sd-id128.h:21,
                 from ../src/systemd/sd-messages.h:20,
                 from ../src/core/manager.c:19:
../src/core/manager.c: In function ‘manager_add_job_by_name’:
/usr/include/string.h:487:14: note: in a call to function ‘basename’ declared here
  487 | extern char *basename (const char *__filename) __THROW __nonnull ((1));
      |              ^~~~~~~~
bug 🐛

Most helpful comment

I see this is marked as closed, but I'm still getting this same error with gcc-10 and systemd-245 and systemd-master clone.

error.txt

>All comments

I see this is marked as closed, but I'm still getting this same error with gcc-10 and systemd-245 and systemd-master clone.

error.txt

Was this page helpful?
0 / 5 - 0 ratings