All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-oe][PATCH] flashrom: Fix build with clang
@ 2020-03-16  0:06 Khem Raj
  2020-03-16  8:02 ` Adrian Bunk
  0 siblings, 1 reply; 4+ messages in thread
From: Khem Raj @ 2020-03-16  0:06 UTC (permalink / raw)
  To: openembedded-devel

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...typecast-enum-conversions-explicitly.patch | 69 +++++++++++++++++++
 meta-oe/recipes-bsp/flashrom/flashrom_1.2.bb  |  1 +
 2 files changed, 70 insertions(+)
 create mode 100644 meta-oe/recipes-bsp/flashrom/flashrom/0001-typecast-enum-conversions-explicitly.patch

diff --git a/meta-oe/recipes-bsp/flashrom/flashrom/0001-typecast-enum-conversions-explicitly.patch b/meta-oe/recipes-bsp/flashrom/flashrom/0001-typecast-enum-conversions-explicitly.patch
new file mode 100644
index 0000000000..7ac53650f2
--- /dev/null
+++ b/meta-oe/recipes-bsp/flashrom/flashrom/0001-typecast-enum-conversions-explicitly.patch
@@ -0,0 +1,69 @@
+From 8a236330f2af56bde21e9f69208ea3e59f529f0c Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Sun, 15 Mar 2020 17:02:30 -0700
+Subject: [PATCH] typecast enum conversions explicitly
+
+clang complains like below
+
+libflashrom.c:191:43: error: implicit conversion from enumeration type 'const enum test_state' to different enumeration type 'enum flashrom_test_state' [-Werror,-Wenum-conversion]
+                        supported_boards[i].working = binfo[i].working;
+                                                    ~ ~~~~~~~~~^~~~~~~
+libflashrom.c:229:46: error: implicit conversion from enumeration type 'const enum test_state' to different enumeration type 'enum flashrom_test_state' [-Werror,-Wenum-conversion]
+                        supported_chipsets[i].status = chipset[i].status;
+                                                     ~ ~~~~~~~~~~~^~~~~~
+
+However these enums are exactly same so they can be typecasted
+
+libflashrom.h
+
+/** @ingroup flashrom-query */
+enum flashrom_test_state {
+        FLASHROM_TESTED_OK  = 0,
+        FLASHROM_TESTED_NT  = 1,
+        FLASHROM_TESTED_BAD = 2,
+        FLASHROM_TESTED_DEP = 3,
+        FLASHROM_TESTED_NA  = 4,
+};
+
+flash.h
+
+enum test_state {
+          OK = 0,
+          NT = 1, /* Not tested */
+          BAD,    /* Known to not work */
+          DEP,    /* Support depends on configuration (e.g. Intel flash descriptor) */
+          NA,     /* Not applicable (e.g. write support on ROM chips) */
+  };
+
+Upstream-Status: Pending
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ libflashrom.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/libflashrom.c b/libflashrom.c
+index 0dec22e..7956685 100644
+--- a/libflashrom.c
++++ b/libflashrom.c
+@@ -188,7 +188,7 @@ struct flashrom_board_info *flashrom_supported_boards(void)
+ 		for (; i < boards_known_size; ++i) {
+ 			supported_boards[i].vendor = binfo[i].vendor;
+ 			supported_boards[i].name = binfo[i].name;
+-			supported_boards[i].working = binfo[i].working;
++			supported_boards[i].working = (enum flashrom_test_state)binfo[i].working;
+ 		}
+ 	} else {
+ 		msg_gerr("Memory allocation error!\n");
+@@ -226,7 +226,7 @@ struct flashrom_chipset_info *flashrom_supported_chipsets(void)
+ 			supported_chipsets[i].chipset = chipset[i].device_name;
+ 			supported_chipsets[i].vendor_id = chipset[i].vendor_id;
+ 			supported_chipsets[i].chipset_id = chipset[i].device_id;
+-			supported_chipsets[i].status = chipset[i].status;
++			supported_chipsets[i].status = (enum flashrom_test_state)chipset[i].status;
+ 	  }
+ 	} else {
+ 		msg_gerr("Memory allocation error!\n");
+-- 
+2.25.1
+
diff --git a/meta-oe/recipes-bsp/flashrom/flashrom_1.2.bb b/meta-oe/recipes-bsp/flashrom/flashrom_1.2.bb
index 17445ac2da..642cec1598 100644
--- a/meta-oe/recipes-bsp/flashrom/flashrom_1.2.bb
+++ b/meta-oe/recipes-bsp/flashrom/flashrom_1.2.bb
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
 DEPENDS = "pciutils libusb libusb-compat"
 
 SRC_URI = "https://download.flashrom.org/releases/flashrom-v${PV}.tar.bz2 \
+           file://0001-typecast-enum-conversions-explicitly.patch \
            "
 SRC_URI[md5sum] = "7f8e4b87087eb12ecee0fcc5445b4956"
 SRC_URI[sha256sum] = "e1f8d95881f5a4365dfe58776ce821dfcee0f138f75d0f44f8a3cd032d9ea42b"
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [meta-oe][PATCH] flashrom: Fix build with clang
@ 2025-03-13 18:38 Khem Raj
  0 siblings, 0 replies; 4+ messages in thread
From: Khem Raj @ 2025-03-13 18:38 UTC (permalink / raw)
  To: openembedded-devel; +Cc: Khem Raj

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...01-linux_mtd-fix-build-with-clang-19.patch | 39 +++++++++++++++++++
 .../recipes-bsp/flashrom/flashrom_1.4.0.bb    |  1 +
 2 files changed, 40 insertions(+)
 create mode 100644 meta-oe/recipes-bsp/flashrom/flashrom/0001-linux_mtd-fix-build-with-clang-19.patch

diff --git a/meta-oe/recipes-bsp/flashrom/flashrom/0001-linux_mtd-fix-build-with-clang-19.patch b/meta-oe/recipes-bsp/flashrom/flashrom/0001-linux_mtd-fix-build-with-clang-19.patch
new file mode 100644
index 0000000000..46bd0bba44
--- /dev/null
+++ b/meta-oe/recipes-bsp/flashrom/flashrom/0001-linux_mtd-fix-build-with-clang-19.patch
@@ -0,0 +1,39 @@
+From 615fae91dafdb89f0f8418129918dbb7ff879cf6 Mon Sep 17 00:00:00 2001
+From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
+Date: Thu, 24 Oct 2024 17:51:29 +0200
+Subject: [PATCH] linux_mtd: fix build with clang >= 19
+
+Starting with version 19, clang issues a warning when using `strlen()`
+for initializing a static array's size. This causes the build to fail as
+the project also sets `-Werror`.
+
+This is fixed by using `sizeof()` instead, which is guaranteed to be
+evaluated at compilation time and therefore not triggering the
+problematic warning.
+
+Upstream-Status: Backport [https://github.com/flashrom/flashrom/commit/34b1a6aa57e910c0b5a518e8a0cab6841c7efaee]
+
+Change-Id: If470a65702e9ae08e4303123a0014e53a1fee56e
+Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
+Reviewed-on: https://review.coreboot.org/c/flashrom/+/84856
+Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
+Reviewed-by: Maximilian Brune <maximilian.brune@9elements.com>
+Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ linux_mtd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/linux_mtd.c b/linux_mtd.c
+index eea0cf2..0cb2330 100644
+--- a/linux_mtd.c
++++ b/linux_mtd.c
+@@ -49,7 +49,7 @@ static int read_sysfs_string(const char *sysfs_path, const char *filename, char
+ 	int i;
+ 	size_t bytes_read;
+ 	FILE *fp;
+-	char path[strlen(LINUX_MTD_SYSFS_ROOT) + 32];
++	char path[sizeof(LINUX_MTD_SYSFS_ROOT) + 31];
+ 
+ 	snprintf(path, sizeof(path), "%s/%s", sysfs_path, filename);
+ 
diff --git a/meta-oe/recipes-bsp/flashrom/flashrom_1.4.0.bb b/meta-oe/recipes-bsp/flashrom/flashrom_1.4.0.bb
index 98447809cf..6c5d05f2d0 100644
--- a/meta-oe/recipes-bsp/flashrom/flashrom_1.4.0.bb
+++ b/meta-oe/recipes-bsp/flashrom/flashrom_1.4.0.bb
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
 SRC_URI = "https://download.flashrom.org/releases/flashrom-v${PV}.tar.xz \
            file://0001-flashrom-Mark-RISCV-as-non-memory-mapped-I-O-archite.patch \
            file://0002-meson-Add-options-pciutils-ftdi-usb.patch \
+           file://0001-linux_mtd-fix-build-with-clang-19.patch \
            "
 
 SRC_URI[sha256sum] = "eb0eb3e61a57fd1926c66f08664cf04a96f92cee23b600cf563087c2178d70d8"


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-03-13 18:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-16  0:06 [meta-oe][PATCH] flashrom: Fix build with clang Khem Raj
2020-03-16  8:02 ` Adrian Bunk
2020-03-16 18:40   ` Khem Raj
  -- strict thread matches above, loose matches on Subject: below --
2025-03-13 18:38 Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.