diff options
author | Khem Raj <raj.khem@gmail.com> | 2023-01-15 10:51:48 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-18 16:42:27 +0000 |
commit | 4d5e40bf773c9ca36e4e2846052dc722ff46e167 (patch) | |
tree | a1ca7472afe54d3c4a15c769aeb299af1f0aa781 | |
parent | 376a27c932db85e665f9532347e8432e46861880 (diff) | |
download | poky-4d5e40bf773c9ca36e4e2846052dc722ff46e167.tar.gz |
libxcb: Fixed c2x standard undefined behaviour
(From OE-Core rev: bf2263f163956d58fa951eb099c021efe5e16ae2)
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>
-rw-r--r-- | meta/recipes-graphics/xorg-lib/libxcb/0001-use-_Alignof-to-avoid-UB-in-ALIGNOF.patch | 45 | ||||
-rw-r--r-- | meta/recipes-graphics/xorg-lib/libxcb_1.15.bb | 3 |
2 files changed, 47 insertions, 1 deletions
diff --git a/meta/recipes-graphics/xorg-lib/libxcb/0001-use-_Alignof-to-avoid-UB-in-ALIGNOF.patch b/meta/recipes-graphics/xorg-lib/libxcb/0001-use-_Alignof-to-avoid-UB-in-ALIGNOF.patch new file mode 100644 index 0000000000..5b159d646d --- /dev/null +++ b/meta/recipes-graphics/xorg-lib/libxcb/0001-use-_Alignof-to-avoid-UB-in-ALIGNOF.patch | |||
@@ -0,0 +1,45 @@ | |||
1 | From d55b6b1fa87700f3eae3a29522972d2e7be7d53e Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 14 Jan 2023 10:11:35 -0800 | ||
4 | Subject: [PATCH] use _Alignof to avoid UB in ALIGNOF | ||
5 | |||
6 | WG14 N2350 clearly says that it is an UB having type definitions | ||
7 | within "offsetof" [1]. Clang 16+ has started diagnosing it [2]. | ||
8 | This patch changes the implementation of macro | ||
9 | "ALIGNOF" to builtin "_Alignof" to avoid undefined behavior. | ||
10 | |||
11 | _Alignof() return the ABI required minimum alignment. | ||
12 | |||
13 | [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm | ||
14 | [2] https://reviews.llvm.org/D133574 | ||
15 | |||
16 | Upstream-Status: Submitted [https://gitlab.freedesktop.org/xorg/lib/libxcb/-/merge_requests/42] | ||
17 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
18 | --- | ||
19 | src/c_client.py | 3 +-- | ||
20 | 1 file changed, 1 insertion(+), 2 deletions(-) | ||
21 | |||
22 | diff --git a/src/c_client.py b/src/c_client.py | ||
23 | index fd256f0..4e48f13 100644 | ||
24 | --- a/src/c_client.py | ||
25 | +++ b/src/c_client.py | ||
26 | @@ -288,7 +288,6 @@ def c_open(self): | ||
27 | _c('#include "%s.h"', _ns.header) | ||
28 | |||
29 | _c('') | ||
30 | - _c('#define ALIGNOF(type) offsetof(struct { char dummy; type member; }, member)') | ||
31 | |||
32 | if _ns.is_ext: | ||
33 | for (n, h) in self.direct_imports: | ||
34 | @@ -1266,7 +1265,7 @@ def _c_serialize_helper_fields(context, self, | ||
35 | count += 1 | ||
36 | |||
37 | code_lines.append( | ||
38 | - '%s xcb_align_to = ALIGNOF(%s);' | ||
39 | + '%s xcb_align_to = _Alignof(%s);' | ||
40 | % (space, | ||
41 | 'char' | ||
42 | if field.c_field_type == 'void' or field.type.is_switch | ||
43 | -- | ||
44 | 2.39.0 | ||
45 | |||
diff --git a/meta/recipes-graphics/xorg-lib/libxcb_1.15.bb b/meta/recipes-graphics/xorg-lib/libxcb_1.15.bb index 839577326e..411f51ac39 100644 --- a/meta/recipes-graphics/xorg-lib/libxcb_1.15.bb +++ b/meta/recipes-graphics/xorg-lib/libxcb_1.15.bb | |||
@@ -9,7 +9,8 @@ SECTION = "x11/libs" | |||
9 | LICENSE = "MIT" | 9 | LICENSE = "MIT" |
10 | LIC_FILES_CHKSUM = "file://COPYING;md5=d763b081cb10c223435b01e00dc0aba7" | 10 | LIC_FILES_CHKSUM = "file://COPYING;md5=d763b081cb10c223435b01e00dc0aba7" |
11 | 11 | ||
12 | SRC_URI = "http://xcb.freedesktop.org/dist/libxcb-${PV}.tar.xz" | 12 | SRC_URI = "http://xcb.freedesktop.org/dist/libxcb-${PV}.tar.xz \ |
13 | file://0001-use-_Alignof-to-avoid-UB-in-ALIGNOF.patch" | ||
13 | 14 | ||
14 | SRC_URI[sha256sum] = "cc38744f817cf6814c847e2df37fcb8997357d72fa4bcbc228ae0fe47219a059" | 15 | SRC_URI[sha256sum] = "cc38744f817cf6814c847e2df37fcb8997357d72fa4bcbc228ae0fe47219a059" |
15 | 16 | ||