diff options
author | Khem Raj <raj.khem@gmail.com> | 2023-01-15 10:51:50 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-18 16:42:27 +0000 |
commit | 376d0fdd0e107a56fa811b7ad6ba80d8dc6a1310 (patch) | |
tree | ba1bbb423f2ffc8f81e6ecd6054cc6f43bd7f474 /meta/recipes-core | |
parent | 4d5e40bf773c9ca36e4e2846052dc722ff46e167 (diff) | |
download | poky-376d0fdd0e107a56fa811b7ad6ba80d8dc6a1310.tar.gz |
dbus: Use Alignof when using C11 or newer standard
Fixes an UB found with with clang
(From OE-Core rev: e1f2d23f1049222fd5aab6189710e89a550ba911)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r-- | meta/recipes-core/dbus/dbus/0001-Define-_DBUS_ALIGNOF-using-_Alignof-when-using-C11-o.patch | 42 | ||||
-rw-r--r-- | meta/recipes-core/dbus/dbus_1.14.4.bb | 1 |
2 files changed, 43 insertions, 0 deletions
diff --git a/meta/recipes-core/dbus/dbus/0001-Define-_DBUS_ALIGNOF-using-_Alignof-when-using-C11-o.patch b/meta/recipes-core/dbus/dbus/0001-Define-_DBUS_ALIGNOF-using-_Alignof-when-using-C11-o.patch new file mode 100644 index 0000000000..7b4e26f99e --- /dev/null +++ b/meta/recipes-core/dbus/dbus/0001-Define-_DBUS_ALIGNOF-using-_Alignof-when-using-C11-o.patch | |||
@@ -0,0 +1,42 @@ | |||
1 | From c3e2c873ffa8e89b5f83dccc4e4e35dfcea633cb Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 14 Jan 2023 12:39:43 -0800 | ||
4 | Subject: [PATCH] Define _DBUS_ALIGNOF using _Alignof when using C11 or newer | ||
5 | |||
6 | WG14 N2350 made very clear that it is an UB having type definitions | ||
7 | within "offsetof" [1]. This patch changes the implementation of macro | ||
8 | _DBUS_ALIGNOF to builtin "_Alignof" to avoid undefined behavior. | ||
9 | |||
10 | clang 16+ has started to diagnose this [2] | ||
11 | |||
12 | Fixes build when using -std >= gnu11 and using clang16+ | ||
13 | |||
14 | [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm | ||
15 | [2] https://reviews.llvm.org/D133574 | ||
16 | |||
17 | Upstream-Status: Submitted [https://gitlab.freedesktop.org/dbus/dbus/-/merge_requests/389] | ||
18 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
19 | --- | ||
20 | dbus/dbus-internals.h | 4 ++++ | ||
21 | 1 file changed, 4 insertions(+) | ||
22 | |||
23 | diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h | ||
24 | index cc98c92a..2387752d 100644 | ||
25 | --- a/dbus/dbus-internals.h | ||
26 | +++ b/dbus/dbus-internals.h | ||
27 | @@ -201,8 +201,12 @@ void _dbus_real_assert_not_reached (const char *explanation, | ||
28 | ((intptr_t) ((unsigned char*) &((struct_type*) 0)->member)) | ||
29 | #endif | ||
30 | |||
31 | +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) | ||
32 | +#define _DBUS_ALIGNOF(type) _Alignof(type) | ||
33 | +#else | ||
34 | #define _DBUS_ALIGNOF(type) \ | ||
35 | (_DBUS_STRUCT_OFFSET (struct { char _1; type _2; }, _2)) | ||
36 | +#endif | ||
37 | |||
38 | #if defined(DBUS_DISABLE_CHECKS) || defined(DBUS_DISABLE_ASSERT) | ||
39 | /* this is an assert and not an error, but in the typical --disable-checks case (you're trying | ||
40 | -- | ||
41 | 2.39.0 | ||
42 | |||
diff --git a/meta/recipes-core/dbus/dbus_1.14.4.bb b/meta/recipes-core/dbus/dbus_1.14.4.bb index 5f91ec2dc1..ee05496203 100644 --- a/meta/recipes-core/dbus/dbus_1.14.4.bb +++ b/meta/recipes-core/dbus/dbus_1.14.4.bb | |||
@@ -13,6 +13,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=6423dcd74d7be9715b0db247fd889da3 \ | |||
13 | SRC_URI = "https://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.xz \ | 13 | SRC_URI = "https://dbus.freedesktop.org/releases/dbus/dbus-${PV}.tar.xz \ |
14 | file://run-ptest \ | 14 | file://run-ptest \ |
15 | file://tmpdir.patch \ | 15 | file://tmpdir.patch \ |
16 | file://0001-Define-_DBUS_ALIGNOF-using-_Alignof-when-using-C11-o.patch \ | ||
16 | file://dbus-1.init \ | 17 | file://dbus-1.init \ |
17 | " | 18 | " |
18 | 19 | ||