diff mbox series

[1/2] systemd: Fix build with gcc9

Message ID 20190506175136.7594-1-raj.khem@gmail.com
State New
Headers show
Series [1/2] systemd: Fix build with gcc9 | expand

Commit Message

Khem Raj May 6, 2019, 5:51 p.m. UTC
gcc9 throws additional warnings about format string overflow

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...-format-overflow-warnings-with-gcc-9.patch | 41 +++++++++++++++++++
 meta/recipes-core/systemd/systemd_242.bb      |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch

Comments

Adrian Bunk May 6, 2019, 6:23 p.m. UTC | #1
On Mon, May 06, 2019 at 10:51:35AM -0700, Khem Raj wrote:
>...
> +gcc-9 has become a bit stricter and can check all kind of formatted
> +input/output functions which causes additional warnings when compiling
> +networkd
> +
> +/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> +         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
>...
> +         if (r < 0)
> +                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
> +-                                       enable_disable(!disabled), link->ifname);
> ++                                       enable_disable(!disabled),
> ++                                       (link->ifname) ? link->ifname : "<null>");
>...

The fix doesn't look correct to me:
gcc says it "is null", so checking whether or not it is null doesn't
match the error message.

If it is a compiler bug as was at some point mentioned upstream,
a better temporary workaround would be to stop making this an error
with -Wno-error=format-overflow (untested).

cu
Adrian
Ross Burton May 13, 2019, 11:27 p.m. UTC | #2
https://github.com/systemd/systemd/commit/c98b3545008d8e984ab456dcf79787418fcbfe13
is the upstream fix, so lets use this instead.

Ross

On Mon, 6 May 2019 at 11:24, Adrian Bunk <bunk@stusta.de> wrote:
>
> On Mon, May 06, 2019 at 10:51:35AM -0700, Khem Raj wrote:
> >...
> > +gcc-9 has become a bit stricter and can check all kind of formatted
> > +input/output functions which causes additional warnings when compiling
> > +networkd
> > +
> > +/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> > +         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
> >...
> > +         if (r < 0)
> > +                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
> > +-                                       enable_disable(!disabled), link->ifname);
> > ++                                       enable_disable(!disabled),
> > ++                                       (link->ifname) ? link->ifname : "<null>");
> >...
>
> The fix doesn't look correct to me:
> gcc says it "is null", so checking whether or not it is null doesn't
> match the error message.
>
> If it is a compiler bug as was at some point mentioned upstream,
> a better temporary workaround would be to stop making this an error
> with -Wno-error=format-overflow (untested).
>
> cu
> Adrian
>
> --
>
>        "Is there not promise of rain?" Ling Tan asked suddenly out
>         of the darkness. There had been need of rain for many days.
>        "Only a promise," Lao Er said.
>                                        Pearl S. Buck - Dragon Seed
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Khem Raj May 14, 2019, 3:21 a.m. UTC | #3
you are late to party but its already applied see oe-core/d5e999616e

On Mon, May 13, 2019 at 7:27 PM Burton, Ross <ross.burton@intel.com> wrote:
>
> https://github.com/systemd/systemd/commit/c98b3545008d8e984ab456dcf79787418fcbfe13
> is the upstream fix, so lets use this instead.
>
> Ross
>
> On Mon, 6 May 2019 at 11:24, Adrian Bunk <bunk@stusta.de> wrote:
> >
> > On Mon, May 06, 2019 at 10:51:35AM -0700, Khem Raj wrote:
> > >...
> > > +gcc-9 has become a bit stricter and can check all kind of formatted
> > > +input/output functions which causes additional warnings when compiling
> > > +networkd
> > > +
> > > +/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> > > +         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
> > >...
> > > +         if (r < 0)
> > > +                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
> > > +-                                       enable_disable(!disabled), link->ifname);
> > > ++                                       enable_disable(!disabled),
> > > ++                                       (link->ifname) ? link->ifname : "<null>");
> > >...
> >
> > The fix doesn't look correct to me:
> > gcc says it "is null", so checking whether or not it is null doesn't
> > match the error message.
> >
> > If it is a compiler bug as was at some point mentioned upstream,
> > a better temporary workaround would be to stop making this an error
> > with -Wno-error=format-overflow (untested).
> >
> > cu
> > Adrian
> >
> > --
> >
> >        "Is there not promise of rain?" Ling Tan asked suddenly out
> >         of the darkness. There had been need of rain for many days.
> >        "Only a promise," Lao Er said.
> >                                        Pearl S. Buck - Dragon Seed
> >
> > --
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core
Ross Burton May 14, 2019, 3:56 a.m. UTC | #4
Huh I checked git too.  Obviously not well enough!

On Mon, 13 May 2019 at 20:22, Khem Raj <raj.khem@gmail.com> wrote:
>
> you are late to party but its already applied see oe-core/d5e999616e
>
> On Mon, May 13, 2019 at 7:27 PM Burton, Ross <ross.burton@intel.com> wrote:
> >
> > https://github.com/systemd/systemd/commit/c98b3545008d8e984ab456dcf79787418fcbfe13
> > is the upstream fix, so lets use this instead.
> >
> > Ross
> >
> > On Mon, 6 May 2019 at 11:24, Adrian Bunk <bunk@stusta.de> wrote:
> > >
> > > On Mon, May 06, 2019 at 10:51:35AM -0700, Khem Raj wrote:
> > > >...
> > > > +gcc-9 has become a bit stricter and can check all kind of formatted
> > > > +input/output functions which causes additional warnings when compiling
> > > > +networkd
> > > > +
> > > > +/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
> > > > +         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
> > > >...
> > > > +         if (r < 0)
> > > > +                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
> > > > +-                                       enable_disable(!disabled), link->ifname);
> > > > ++                                       enable_disable(!disabled),
> > > > ++                                       (link->ifname) ? link->ifname : "<null>");
> > > >...
> > >
> > > The fix doesn't look correct to me:
> > > gcc says it "is null", so checking whether or not it is null doesn't
> > > match the error message.
> > >
> > > If it is a compiler bug as was at some point mentioned upstream,
> > > a better temporary workaround would be to stop making this an error
> > > with -Wno-error=format-overflow (untested).
> > >
> > > cu
> > > Adrian
> > >
> > > --
> > >
> > >        "Is there not promise of rain?" Ling Tan asked suddenly out
> > >         of the darkness. There had been need of rain for many days.
> > >        "Only a promise," Lao Er said.
> > >                                        Pearl S. Buck - Dragon Seed
> > >
> > > --
> > > _______________________________________________
> > > Openembedded-core mailing list
> > > Openembedded-core@lists.openembedded.org
> > > http://lists.openembedded.org/mailman/listinfo/openembedded-core
diff mbox series

Patch

diff --git a/meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch b/meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch
new file mode 100644
index 0000000000..510ac22150
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0006-Fix-format-overflow-warnings-with-gcc-9.patch
@@ -0,0 +1,41 @@ 
+From c8050da8b7b0e59e4d1d0e15a92b9ecad299dbbb Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 6 May 2019 10:41:15 -0700
+Subject: [PATCH] Fix format-overflow warnings with gcc-9
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+gcc-9 has become a bit stricter and can check all kind of formatted
+input/output functions which causes additional warnings when compiling
+networkd
+
+/src/basic/log.h:104:9: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
+         log_internal_realm(LOG_REALM_PLUS_LEVEL(LOG_REALM, (level)), __VA_ARGS__)
+
+see https://github.com/systemd/systemd/issues/12454
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ src/network/networkd-link.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
+index 533193ac93..976cbbeaaa 100644
+--- a/src/network/networkd-link.c
++++ b/src/network/networkd-link.c
+@@ -339,7 +339,8 @@ static int link_enable_ipv6(Link *link) {
+         r = sysctl_write_ip_property_boolean(AF_INET6, link->ifname, "disable_ipv6", disabled);
+         if (r < 0)
+                 log_link_warning_errno(link, r, "Cannot %s IPv6 for interface %s: %m",
+-                                       enable_disable(!disabled), link->ifname);
++                                       enable_disable(!disabled),
++                                       (link->ifname) ? link->ifname : "<null>");
+         else
+                 log_link_info(link, "IPv6 successfully %sd", enable_disable(!disabled));
+ 
+-- 
+2.21.0
+
diff --git a/meta/recipes-core/systemd/systemd_242.bb b/meta/recipes-core/systemd/systemd_242.bb
index a6b39d57e8..93c4472bab 100644
--- a/meta/recipes-core/systemd/systemd_242.bb
+++ b/meta/recipes-core/systemd/systemd_242.bb
@@ -22,6 +22,7 @@  SRC_URI += "file://touchscreen.rules \
            file://0003-implment-systemd-sysv-install-for-OE.patch \
            file://0004-rules-whitelist-hd-devices.patch \
            file://0005-rules-watch-metadata-changes-in-ide-devices.patch \
+           file://0006-Fix-format-overflow-warnings-with-gcc-9.patch \
            file://99-default.preset \
            "