From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by mail.openembedded.org (Postfix) with ESMTP id 0E61074FFF for ; Fri, 1 Jun 2018 14:48:22 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id d2-v6so21149895wrm.10 for ; Fri, 01 Jun 2018 07:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Tp5s6PTCry3qZ5jp+OA78f85czhjMkzMWa/h/3+RUgU=; b=hlJj3reng+n3Bwcu5Ng6OqtNc/Bmqdfs1OYc7wcoIol/N3h9QZ1JMXodSdD3v+cpV8 qceBsxna6RUtFo+JOfK48kg003dT0jBPa1U6sdDRgbhmh4ibcgN7VVD3nEJFF5NmQJk5 f+BGQ+A8iiEb+R2ZBI1JuOKOsSR5nyMbIK7QnhV4Jv0/4JrbH8Ji6hb/NBh+2XO0e1WC efwGTmRgk3EUYp9fFWTQfFcGd1qpGadu/LsqlfOCR+zXo0O1GMOYkVAxHov21BWOTZGE jzN6pdQMdt1D7DAuS8Nyg/uaS4nitvSGRU594HXtShTYdUDc/Ln/pjnnzGHB0+heXOl6 YMIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tp5s6PTCry3qZ5jp+OA78f85czhjMkzMWa/h/3+RUgU=; b=XAR7JK5fQVnBgdZ9FlwMKaWk3DmynQgirAmLcQ+FWI2Qk50kltatlYdaNHxtKzmcXe vhClrsECX9j3L/DEXAWZPjQ3F7KpFW1A1AzidAjwYpv1hmLqSRCkIjDHQ4hCnZIXqKIL H3qP1l2a1AF7RIDIR9BuZWaByhSkNkkg/PmO/FsprKwvinktB2sn3QKeuJQfUmQ3UTax RKZugK29OxlvrZ7jsI2feWWmRx/qBTSJKC/vmQaCuhKRfEbf6w89y19TY+6T4YbMCguK 1C/G/tt1hm0OtZCrJAX7XAw4fJ00JbbGkRvXIxYYIfdpw44PN0kDtoN7Ni7kdH/57/5s 6Alw== X-Gm-Message-State: ALKqPwe4qcBG0/8pmsTF70U38tT3yHqjtLrpcOWJQrPMHWwksw7Ns6MG itt/ZjCyQcAquvQ/G15ymSqqQMZTvrzCTzh0DbHV5Q== X-Google-Smtp-Source: ADUXVKKMLGH946qwBOVBE3S3OtsrktcYG0zTvrOVCAXjEwAGd7Mi7WeSb+XOClJOiNPR1IvSlCnvbKnsNoETtCf/d+8= X-Received: by 2002:adf:9561:: with SMTP id 88-v6mr4609680wrs.223.1527864503553; Fri, 01 Jun 2018 07:48:23 -0700 (PDT) MIME-Version: 1.0 References: <20180528155833.24224-1-raj.khem@gmail.com> In-Reply-To: From: Martin Jansa Date: Fri, 1 Jun 2018 16:48:14 +0200 Message-ID: To: Khem Raj Cc: Patches and discussions about the oe-core layer Subject: Re: [PATCH 1/3] systemd: Fix build with gcc8 X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2018 14:48:23 -0000 Content-Type: multipart/alternative; boundary="000000000000ffd408056d95acb2" --000000000000ffd408056d95acb2 Content-Type: text/plain; charset="UTF-8" It fails when -O1 or -Os is being used, builds ok with -O0, -O2, -O3. Checking a bit more shows that it doesn't fail when -ftree-vrp is used, probably because this check is removed as the documentation for -ftree-vrp says: -ftree-vrp Perform Value Range Propagation on trees. This is similar to the constant propagation pass, but instead of values, ranges of values are propagated. This allows the optimizers to remove unnecessary range checks like array bound checks and null pointer checks. This is enabled by default at -O2 and higher. Null pointer check elimination is only done if -fdelete-null-pointer-checks is enabled. On Fri, Jun 1, 2018 at 4:01 PM Martin Jansa wrote: > No change in PACKAGECONFIG, just default nodistro qemux86 with added > systemd and debug build: > DISTRO_FEATURES_append = " systemd" > DEBUG_BUILD = "1" > > > On Thu, May 31, 2018 at 6:17 PM Khem Raj wrote: > >> On Thu, May 31, 2018 at 9:05 AM, Martin Jansa >> wrote: >> > Unlike the previous version you had in your RFT branch (which added >> > -Wno-error=format-truncation) this doesn't seem to be complete fix. >> > >> > In qemux86 build which already includes this change I'm seeing: >> > ../git/src/basic/time-util.c: In function 'format_timespan': >> > ../git/src/basic/time-util.c:508:46: error: '%0*llu' directive output >> > between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX' >> > [-Werror=format-truncation=] >> > >> > "%s"USEC_FMT".%0*"PRI_USEC"%s", >> > ^~~~ >> > ../git/src/basic/time-util.c:508:60: note: format string is defined here >> > >> > "%s"USEC_FMT".%0*"PRI_USEC"%s", >> > ../git/src/basic/time-util.c:508:46: note: directive argument in the >> range >> > [0, 18446744073709551614] >> > >> > "%s"USEC_FMT".%0*"PRI_USEC"%s", >> > ^~~~ >> > >> > And this part doesn't seem to be fixed upstream yet. >> > >> >> Its possible, that default config I build is not using this code. Do >> you enable/disable some specific packageconfig and what arch are you >> targetting >> >> > Cheers, >> > >> > On Mon, May 28, 2018 at 5:58 PM Khem Raj wrote: >> >> >> >> Signed-off-by: Khem Raj >> >> --- >> >> ...ange-the-default-device-timeout-to-2.patch | 9 +- >> >> ...ation-compile-failure-by-typecasting.patch | 173 ++++++++++++++++++ >> >> meta/recipes-core/systemd/systemd_237.bb | 1 + >> >> 3 files changed, 177 insertions(+), 6 deletions(-) >> >> create mode 100644 >> >> >> meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch >> >> >> >> diff --git >> >> >> a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch >> >> >> b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch >> >> index b7b1ea0886..98c83620ff 100644 >> >> --- >> >> >> a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch >> >> +++ >> >> >> b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-default-device-timeout-to-2.patch >> >> @@ -1,4 +1,4 @@ >> >> -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00 2001 >> >> +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00 2001 >> >> From: Khem Raj >> >> Date: Mon, 14 Dec 2015 04:09:19 +0000 >> >> Subject: [PATCH] core/device.c: Change the default device timeout to >> 240 >> >> sec. >> >> @@ -16,10 +16,10 @@ Signed-off-by: Khem Raj >> >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> >> >> diff --git a/src/core/device.c b/src/core/device.c >> >> -index 77601c552..98bf49ba2 100644 >> >> +index a43664d3b..4b16a8aec 100644 >> >> --- a/src/core/device.c >> >> +++ b/src/core/device.c >> >> -@@ -112,7 +112,7 @@ static void device_init(Unit *u) { >> >> +@@ -113,7 +113,7 @@ static void device_init(Unit *u) { >> >> * indefinitely for plugged in devices, something which >> cannot >> >> * happen for the other units since their operations time out >> >> * anyway. */ >> >> @@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644 >> >> >> >> u->ignore_on_isolate = true; >> >> } >> >> --- >> >> -2.16.1 >> >> - >> >> diff --git >> >> >> a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch >> >> >> b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch >> >> new file mode 100644 >> >> index 0000000000..e56061f41b >> >> --- /dev/null >> >> +++ >> >> >> b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compile-failure-by-typecasting.patch >> >> @@ -0,0 +1,173 @@ >> >> +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00 2001 >> >> +From: Patrick Uiterwijk >> >> +Date: Thu, 22 Feb 2018 19:41:30 +0100 >> >> +Subject: [PATCH] Fix format-truncation compile failure by typecasting >> USB >> >> IDs >> >> + (#8250) >> >> + >> >> +This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bit >> >> int, and >> >> +uses that for parsing USB device and vendor IDs. >> >> + >> >> +This fixes a compile error with gcc-8 because while we know that USB >> IDs >> >> are 2 bytes, >> >> +the compiler does not know that. >> >> + >> >> +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output >> may >> >> be >> >> +truncated writing between 4 and 8 bytes into a region of size between >> 2 >> >> and 6 >> >> +[-Werror=format-truncation=] >> >> + >> >> +Upstream-Status: Backport >> >> [ >> https://github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd >> ] >> >> + >> >> +Signed-off-by: Adam Williamson >> >> +Signed-off-by: Patrick Uiterwijk >> >> +--- >> >> + src/basic/parse-util.c | 24 ++++++++++++++++++++++ >> >> + src/basic/parse-util.h | 2 ++ >> >> + src/test/test-parse-util.c | 39 >> ++++++++++++++++++++++++++++++++++++ >> >> + src/udev/udev-builtin-hwdb.c | 13 ++++++------ >> >> + 4 files changed, 71 insertions(+), 7 deletions(-) >> >> + >> >> +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c >> >> +index 97533721d..ff3fc298a 100644 >> >> +--- a/src/basic/parse-util.c >> >> ++++ b/src/basic/parse-util.c >> >> +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret) { >> >> + return 0; >> >> + } >> >> + >> >> ++int safe_atoux16(const char *s, uint16_t *ret) { >> >> ++ char *x = NULL; >> >> ++ unsigned long l; >> >> ++ >> >> ++ assert(s); >> >> ++ assert(ret); >> >> ++ >> >> ++ s += strspn(s, WHITESPACE); >> >> ++ >> >> ++ errno = 0; >> >> ++ l = strtoul(s, &x, 16); >> >> ++ if (errno > 0) >> >> ++ return -errno; >> >> ++ if (!x || x == s || *x != 0) >> >> ++ return -EINVAL; >> >> ++ if (s[0] == '-') >> >> ++ return -ERANGE; >> >> ++ if ((unsigned long) (uint16_t) l != l) >> >> ++ return -ERANGE; >> >> ++ >> >> ++ *ret = (uint16_t) l; >> >> ++ return 0; >> >> ++} >> >> ++ >> >> + int safe_atod(const char *s, double *ret_d) { >> >> + _cleanup_(freelocalep) locale_t loc = (locale_t) 0; >> >> + char *x = NULL; >> >> +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h >> >> +index 1eda1d7f9..727422056 100644 >> >> +--- a/src/basic/parse-util.h >> >> ++++ b/src/basic/parse-util.h >> >> +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); >> >> + int safe_atou16(const char *s, uint16_t *ret); >> >> + int safe_atoi16(const char *s, int16_t *ret); >> >> + >> >> ++int safe_atoux16(const char *s, uint16_t *ret); >> >> ++ >> >> + static inline int safe_atou32(const char *s, uint32_t *ret_u) { >> >> + assert_cc(sizeof(uint32_t) == sizeof(unsigned)); >> >> + return safe_atou(s, (unsigned*) ret_u); >> >> +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-util.c >> >> +index 937500213..a99cea5a1 100644 >> >> +--- a/src/test/test-parse-util.c >> >> ++++ b/src/test/test-parse-util.c >> >> +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) { >> >> + assert_se(r == -EINVAL); >> >> + } >> >> + >> >> ++static void test_safe_atoux16(void) { >> >> ++ int r; >> >> ++ uint16_t l; >> >> ++ >> >> ++ r = safe_atoux16("1234", &l); >> >> ++ assert_se(r == 0); >> >> ++ assert_se(l == 0x1234); >> >> ++ >> >> ++ r = safe_atoux16("abcd", &l); >> >> ++ assert_se(r == 0); >> >> ++ assert_se(l == 0xabcd); >> >> ++ >> >> ++ r = safe_atoux16(" 1234", &l); >> >> ++ assert_se(r == 0); >> >> ++ assert_se(l == 0x1234); >> >> ++ >> >> ++ r = safe_atoux16("12345", &l); >> >> ++ assert_se(r == -ERANGE); >> >> ++ >> >> ++ r = safe_atoux16("-1", &l); >> >> ++ assert_se(r == -ERANGE); >> >> ++ >> >> ++ r = safe_atoux16(" -1", &l); >> >> ++ assert_se(r == -ERANGE); >> >> ++ >> >> ++ r = safe_atoux16("junk", &l); >> >> ++ assert_se(r == -EINVAL); >> >> ++ >> >> ++ r = safe_atoux16("123x", &l); >> >> ++ assert_se(r == -EINVAL); >> >> ++ >> >> ++ r = safe_atoux16("12.3", &l); >> >> ++ assert_se(r == -EINVAL); >> >> ++ >> >> ++ r = safe_atoux16("", &l); >> >> ++ assert_se(r == -EINVAL); >> >> ++} >> >> ++ >> >> + static void test_safe_atou64(void) { >> >> + int r; >> >> + uint64_t l; >> >> +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) { >> >> + test_safe_atolli(); >> >> + test_safe_atou16(); >> >> + test_safe_atoi16(); >> >> ++ test_safe_atoux16(); >> >> + test_safe_atou64(); >> >> + test_safe_atoi64(); >> >> + test_safe_atod(); >> >> +diff --git a/src/udev/udev-builtin-hwdb.c >> b/src/udev/udev-builtin-hwdb.c >> >> +index ca7f7c230..dbfe02429 100644 >> >> +--- a/src/udev/udev-builtin-hwdb.c >> >> ++++ b/src/udev/udev-builtin-hwdb.c >> >> +@@ -27,6 +27,7 @@ >> >> + >> >> + #include "alloc-util.h" >> >> + #include "hwdb-util.h" >> >> ++#include "parse-util.h" >> >> + #include "string-util.h" >> >> + #include "udev-util.h" >> >> + #include "udev.h" >> >> +@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(struct udev_device >> *dev, >> >> + >> >> + static const char *modalias_usb(struct udev_device *dev, char *s, >> size_t >> >> size) { >> >> + const char *v, *p; >> >> +- int vn, pn; >> >> ++ uint16_t vn, pn; >> >> + >> >> + v = udev_device_get_sysattr_value(dev, "idVendor"); >> >> + if (!v) >> >> +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_device >> >> *dev, char *s, size_t size) { >> >> + p = udev_device_get_sysattr_value(dev, "idProduct"); >> >> + if (!p) >> >> + return NULL; >> >> +- vn = strtol(v, NULL, 16); >> >> +- if (vn <= 0) >> >> +- return NULL; >> >> +- pn = strtol(p, NULL, 16); >> >> +- if (pn <= 0) >> >> +- return NULL; >> >> ++ if (safe_atoux16(v, &vn) < 0) >> >> ++ return NULL; >> >> ++ if (safe_atoux16(p, &pn) < 0) >> >> ++ return NULL; >> >> + snprintf(s, size, "usb:v%04Xp%04X*", vn, pn); >> >> + return s; >> >> + } >> >> +-- >> >> +2.17.0 >> >> + >> >> diff --git a/meta/recipes-core/systemd/systemd_237.bb >> >> b/meta/recipes-core/systemd/systemd_237.bb >> >> index b7c2113255..c4743a6b9d 100644 >> >> --- a/meta/recipes-core/systemd/systemd_237.bb >> >> +++ b/meta/recipes-core/systemd/systemd_237.bb >> >> @@ -52,6 +52,7 @@ SRC_URI += "file://touchscreen.rules \ >> >> file://0032-memfd.patch \ >> >> >> >> file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patch \ >> >> file://libmount.patch \ >> >> + >> >> file://0034-Fix-format-truncation-compile-failure-by-typecasting.patch >> \ >> >> " >> >> SRC_URI_append_qemuall = " >> >> file://0001-core-device.c-Change-the-default-device-timeout-to-2.patch" >> >> >> >> -- >> >> 2.17.0 >> >> >> >> -- >> >> _______________________________________________ >> >> Openembedded-core mailing list >> >> Openembedded-core@lists.openembedded.org >> >> http://lists.openembedded.org/mailman/listinfo/openembedded-core >> > --000000000000ffd408056d95acb2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It fails when -O1 or -Os is being used, builds ok with -O0= , -O2, -O3.

Checking a bit more shows that it doesn'= t fail when -ftree-vrp is used, probably because this check is removed as t= he documentation for -ftree-vrp says:

-ftree-= vrp
Perform Value Range Propagation on trees. This is similar to = the constant propagation pass, but instead of values, ranges of values are = propagated. This allows the optimizers to remove unnecessary range checks l= ike array bound checks and null pointer checks. This is enabled by default = at -O2 and higher. Null pointer check elimination is only done if -fdelete-= null-pointer-checks is enabled.



On Thu, May 31, 2018 at 9:05 AM, Martin Jansa <martin.jansa@gmail.com> wrote= :
> Unlike the previous version you had in your RFT branch (which added > -Wno-error=3Dformat-truncation) this doesn't seem to be complete f= ix.
>
> In qemux86 build which already includes this change I'm seeing: > ../git/src/basic/time-util.c: In function 'format_timespan': > ../git/src/basic/time-util.c:508:46: error: '%0*llu' directive= output
> between 1 and 2147483647 bytes may cause result to exceed 'INT_MAX= '
> [-Werror=3Dformat-truncation=3D]
>
> "%s"USEC_FMT".%0*"PRI_USEC"%s",
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0^~~~
> ../git/src/basic/time-util.c:508:60: note: format string is defined he= re
>
> "%s"USEC_FMT".%0*"PRI_USEC"%s",
> ../git/src/basic/time-util.c:508:46: note: directive argument in the r= ange
> [0, 18446744073709551614]
>
> "%s"USEC_FMT".%0*"PRI_USEC"%s",
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0^~~~
>
> And this part doesn't seem to be fixed upstream yet.
>

Its possible, that default config I build is not using this code. Do
you enable/disable some specific packageconfig and what arch are you
targetting

> Cheers,
>
> On Mon, May 28, 2018 at 5:58 PM Khem Raj <raj.khem@gmail.com> wrote:
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> ---
>>=C2=A0 ...ange-the-default-device-timeout-to-2.patch |=C2=A0 =C2=A0= 9 +-
>>=C2=A0 ...ation-compile-failure-by-typecasting.patch | 173 ++++++++= ++++++++++
>>=C2=A0 meta/recipes-core/systemd/systemd_237.bb=C2=A0 =C2=A0 =C2=A0= |=C2=A0 =C2=A01 +
>>=C2=A0 3 files changed, 177 insertions(+), 6 deletions(-)
>>=C2=A0 create mode 100644
>> meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-compi= le-failure-by-typecasting.patch
>>
>> diff --git
>> a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-= default-device-timeout-to-2.patch
>> b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-= default-device-timeout-to-2.patch
>> index b7b1ea0886..98c83620ff 100644
>> ---
>> a/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-= default-device-timeout-to-2.patch
>> +++
>> b/meta/recipes-core/systemd/systemd/0001-core-device.c-Change-the-= default-device-timeout-to-2.patch
>> @@ -1,4 +1,4 @@
>> -From 9820c165a9e559cf851e3beb60fad2571de4ded2 Mon Sep 17 00:00:00= 2001
>> +From 7844e070745611a52e355b73e7890f360dd540d0 Mon Sep 17 00:00:00= 2001
>>=C2=A0 From: Khem Raj <raj.khem@gmail.com>
>>=C2=A0 Date: Mon, 14 Dec 2015 04:09:19 +0000
>>=C2=A0 Subject: [PATCH] core/device.c: Change the default device ti= meout to 240
>> sec.
>> @@ -16,10 +16,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
>>=C2=A0 =C2=A01 file changed, 1 insertion(+), 1 deletion(-)
>>
>>=C2=A0 diff --git a/src/core/device.c b/src/core/device.c
>> -index 77601c552..98bf49ba2 100644
>> +index a43664d3b..4b16a8aec 100644
>>=C2=A0 --- a/src/core/device.c
>>=C2=A0 +++ b/src/core/device.c
>> -@@ -112,7 +112,7 @@ static void device_init(Unit *u) {
>> +@@ -113,7 +113,7 @@ static void device_init(Unit *u) {
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * indefinitely for plugge= d in devices, something which cannot
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * happen for the other un= its since their operations time out
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * anyway. */
>> @@ -28,6 +28,3 @@ index 77601c552..98bf49ba2 100644
>>
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0u->ignore_on_isolate = =3D true;
>>=C2=A0 =C2=A0}
>> ---
>> -2.16.1
>> -
>> diff --git
>> a/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-com= pile-failure-by-typecasting.patch
>> b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-com= pile-failure-by-typecasting.patch
>> new file mode 100644
>> index 0000000000..e56061f41b
>> --- /dev/null
>> +++
>> b/meta/recipes-core/systemd/systemd/0034-Fix-format-truncation-com= pile-failure-by-typecasting.patch
>> @@ -0,0 +1,173 @@
>> +From c2b3ebe112ebfd9f9e82fb1531ee225c3152ca83 Mon Sep 17 00:00:00= 2001
>> +From: Patrick Uiterwijk <patrick@puiterwijk.org>
>> +Date: Thu, 22 Feb 2018 19:41:30 +0100
>> +Subject: [PATCH] Fix format-truncation compile failure by typecas= ting USB
>> IDs
>> + (#8250)
>> +
>> +This patch adds safe_atoux16 for parsing an unsigned hexadecimal = 16bit
>> int, and
>> +uses that for parsing USB device and vendor IDs.
>> +
>> +This fixes a compile error with gcc-8 because while we know that = USB IDs
>> are 2 bytes,
>> +the compiler does not know that.
>> +
>> +../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' dire= ctive output may
>> be
>> +truncated writing between 4 and 8 bytes into a region of size bet= ween 2
>> and 6
>> +[-Werror=3Dformat-truncation=3D]
>> +
>> +Upstream-Status: Backport
>> [https://= github.com/systemd/systemd/commit/5547c12503a683290eaed47954ffcfb2d1bc03cd<= /a>]
>> +
>> +Signed-off-by: Adam Williamson <
awilliam@redhat.com>
>> +Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
>> +---
>> + src/basic/parse-util.c=C2=A0 =C2=A0 =C2=A0 =C2=A0| 24 ++++++++++= ++++++++++++
>> + src/basic/parse-util.h=C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 2 ++ >> + src/test/test-parse-util.c=C2=A0 =C2=A0| 39 ++++++++++++++++++++= ++++++++++++++++
>> + src/udev/udev-builtin-hwdb.c | 13 ++++++------
>> + 4 files changed, 71 insertions(+), 7 deletions(-)
>> +
>> +diff --git a/src/basic/parse-util.c b/src/basic/parse-util.c
>> +index 97533721d..ff3fc298a 100644
>> +--- a/src/basic/parse-util.c
>> ++++ b/src/basic/parse-util.c
>> +@@ -532,6 +532,30 @@ int safe_atoi16(const char *s, int16_t *ret)= {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0;
>> + }
>> +
>> ++int safe_atoux16(const char *s, uint16_t *ret) {
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *x =3D NULL;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 unsigned long l;
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(s);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert(ret);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 s +=3D strspn(s, WHITESPACE);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 errno =3D 0;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 l =3D strtoul(s, &x, 16);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (errno > 0)
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -= errno;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!x || x =3D=3D s || *x !=3D 0) >> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -= EINVAL;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (s[0] =3D=3D '-')
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -= ERANGE;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((unsigned long) (uint16_t) l != =3D l)
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return -= ERANGE;
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 *ret =3D (uint16_t) l;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 return 0;
>> ++}
>> ++
>> + int safe_atod(const char *s, double *ret_d) {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0_cleanup_(freelocalep) locale_t= loc =3D (locale_t) 0;
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0char *x =3D NULL;
>> +diff --git a/src/basic/parse-util.h b/src/basic/parse-util.h
>> +index 1eda1d7f9..727422056 100644
>> +--- a/src/basic/parse-util.h
>> ++++ b/src/basic/parse-util.h
>> +@@ -54,6 +54,8 @@ int safe_atou8(const char *s, uint8_t *ret); >> + int safe_atou16(const char *s, uint16_t *ret);
>> + int safe_atoi16(const char *s, int16_t *ret);
>> +
>> ++int safe_atoux16(const char *s, uint16_t *ret);
>> ++
>> + static inline int safe_atou32(const char *s, uint32_t *ret_u) {<= br> >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assert_cc(sizeof(uint32_t) =3D= =3D sizeof(unsigned));
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return safe_atou(s, (unsigned*)= ret_u);
>> +diff --git a/src/test/test-parse-util.c b/src/test/test-parse-uti= l.c
>> +index 937500213..a99cea5a1 100644
>> +--- a/src/test/test-parse-util.c
>> ++++ b/src/test/test-parse-util.c
>> +@@ -468,6 +468,44 @@ static void test_safe_atoi16(void) {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0assert_se(r =3D=3D -EINVAL); >> + }
>> +
>> ++static void test_safe_atoux16(void) {
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 int r;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 uint16_t l;
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("1234",= &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D 0);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(l =3D=3D 0x1234);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("abcd",= &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D 0);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(l =3D=3D 0xabcd);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("=C2=A0 1234= ", &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D 0);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(l =3D=3D 0x1234);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("12345"= , &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -ERANGE);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("-1", &= amp;l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -ERANGE);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("=C2=A0 -1&q= uot;, &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -ERANGE);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("junk",= &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -EINVAL);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("123x",= &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -EINVAL);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("12.3",= &l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -EINVAL);
>> ++
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 r =3D safe_atoux16("", &am= p;l);
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 assert_se(r =3D=3D -EINVAL);
>> ++}
>> ++
>> + static void test_safe_atou64(void) {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int r;
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0uint64_t l;
>> +@@ -745,6 +783,7 @@ int main(int argc, char *argv[]) {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_safe_atolli();
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_safe_atou16();
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_safe_atoi16();
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 test_safe_atoux16();
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_safe_atou64();
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_safe_atoi64();
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0test_safe_atod();
>> +diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin= -hwdb.c
>> +index ca7f7c230..dbfe02429 100644
>> +--- a/src/udev/udev-builtin-hwdb.c
>> ++++ b/src/udev/udev-builtin-hwdb.c
>> +@@ -27,6 +27,7 @@
>> +
>> + #include "alloc-util.h"
>> + #include "hwdb-util.h"
>> ++#include "parse-util.h"
>> + #include "string-util.h"
>> + #include "udev-util.h"
>> + #include "udev.h"
>> +@@ -63,7 +64,7 @@ int udev_builtin_hwdb_lookup(struct udev_device= *dev,
>> +
>> + static const char *modalias_usb(struct udev_device *dev, char *s= , size_t
>> size) {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0const char *v, *p;
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 int vn, pn;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 uint16_t vn, pn;
>> +
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0v =3D udev_device_get_sysattr_v= alue(dev, "idVendor");
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!v)
>> +@@ -71,12 +72,10 @@ static const char *modalias_usb(struct udev_d= evice
>> *dev, char *s, size_t size) {
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0p =3D udev_device_get_sysattr_v= alue(dev, "idProduct");
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!p)
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret= urn NULL;
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 vn =3D strtol(v, NULL, 16);
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (vn <=3D 0)
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return N= ULL;
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 pn =3D strtol(p, NULL, 16);
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (pn <=3D 0)
>> +-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return N= ULL;
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (safe_atoux16(v, &vn) < 0)=
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return NULL; >> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (safe_atoux16(p, &pn) < 0)=
>> ++=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return NULL; >> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0snprintf(s, size, "usb:v%0= 4Xp%04X*", vn, pn);
>> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return s;
>> + }
>> +--
>> +2.17.0
>> +
>> diff --git a/meta/recipes-core/systemd/systemd_237.bb
>> b/meta/recipes-core/systemd/systemd_237.bb
>> index b7c2113255..c4743a6b9d 100644
>> --- a/meta/recipes-core/systemd/systemd_237.bb
>> +++ b/meta/recipes-core/systemd/systemd_237.bb
>> @@ -52,6 +52,7 @@ SRC_URI +=3D "file://touchscreen.rules \ >>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0file://0032-memfd.p= atch \
>>
>> file://0033-basic-macros-rename-noreturn-into-_noreturn_-8456.patc= h \
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0file://libmount.pat= ch \
>> +
>> file://0034-Fix-format-truncation-compile-failure-by-typecasting.p= atch \
>>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"
>>=C2=A0 SRC_URI_append_qemuall =3D "
>> file://0001-core-device.c-Change-the-default-device-timeout-to-2.p= atch"
>>
>> --
>> 2.17.0
>>
>> --
>> _______________________________________________
>> Openembedded-core mailing list
>> Openembedded-core@lists.openembedded.org
>> http://lists.openembedded.o= rg/mailman/listinfo/openembedded-core
--000000000000ffd408056d95acb2--