1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

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.

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>
This commit is contained in:
Arnaud Ferraris 2024-10-24 17:51:29 +02:00 committed by Anastasia Klimchuk
parent 9ff3d4cf75
commit 34b1a6aa57

View File

@ -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);