From eb0d2f169960cede3ab289343676740ab644816f Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 10 Jan 2025 15:18:11 -0800 Subject: [PATCH 1/2] tests: mgmt: mcumgr: Disable erroneous clang warning tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c:69:22: error: variable 'test_response_read_data_start' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static const uint8_t test_response_read_data_start[5] = { ^ tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c:73:22: error: variable 'test_response_read_data_end' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static const uint8_t test_response_read_data_end[1] = { ^ Signed-off-by: Tom Hughes --- include/zephyr/toolchain/llvm.h | 3 ++- tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/zephyr/toolchain/llvm.h b/include/zephyr/toolchain/llvm.h index cc131246d0a8..541b4ded99b1 100644 --- a/include/zephyr/toolchain/llvm.h +++ b/include/zephyr/toolchain/llvm.h @@ -30,7 +30,8 @@ #include -#define TOOLCHAIN_WARNING_SIZEOF_ARRAY_DECAY "-Wsizeof-array-decay" +#define TOOLCHAIN_WARNING_SIZEOF_ARRAY_DECAY "-Wsizeof-array-decay" +#define TOOLCHAIN_WARNING_UNNEEDED_INTERNAL_DECLARATION "-Wunneeded-internal-declaration" #define TOOLCHAIN_DISABLE_CLANG_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(clang, warning) #define TOOLCHAIN_ENABLE_CLANG_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(clang, warning) diff --git a/tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c b/tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c index e5da57b40096..2be2765a491d 100644 --- a/tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c +++ b/tests/subsys/mgmt/mcumgr/settings_mgmt/src/main.c @@ -66,6 +66,8 @@ static const uint8_t test_response_error_data[8] = { 0xbf, 0x62, 0x72, 0x63, 0x19, 0x01, 0x00, 0xff }; +/* Disable erroneous clang warning: https://github.com/llvm/llvm-project/issues/25458. */ +TOOLCHAIN_DISABLE_CLANG_WARNING(TOOLCHAIN_WARNING_UNNEEDED_INTERNAL_DECLARATION) static const uint8_t test_response_read_data_start[5] = { 0xbf, 0x63, 0x76, 0x61, 0x6c }; @@ -73,6 +75,7 @@ static const uint8_t test_response_read_data_start[5] = { static const uint8_t test_response_read_data_end[1] = { 0xff }; +TOOLCHAIN_ENABLE_CLANG_WARNING(TOOLCHAIN_WARNING_UNNEEDED_INTERNAL_DECLARATION) static void cleanup_test(void *p) { From 8db4009a28e0e46e10fde3b046c76173f5a743ae Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Fri, 10 Jan 2025 15:19:02 -0800 Subject: [PATCH 2/2] tests: subsys: usb: bos: Disable erroneous clang warning tests/subsys/usb/bos/src/test_bos.c:24:22: error: variable 'dummy_descriptor' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static const uint8_t dummy_descriptor[] = { ^ Signed-off-by: Tom Hughes --- tests/subsys/usb/bos/src/test_bos.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/subsys/usb/bos/src/test_bos.c b/tests/subsys/usb/bos/src/test_bos.c index e9452d86fc30..6aec691f22c3 100644 --- a/tests/subsys/usb/bos/src/test_bos.c +++ b/tests/subsys/usb/bos/src/test_bos.c @@ -21,9 +21,12 @@ LOG_MODULE_REGISTER(test_main, LOG_LEVEL_DBG); * Compare old style USB BOS definition with section aligned */ +/* Disable erroneous clang warning: https://github.com/llvm/llvm-project/issues/25458. */ +TOOLCHAIN_DISABLE_CLANG_WARNING(TOOLCHAIN_WARNING_UNNEEDED_INTERNAL_DECLARATION) static const uint8_t dummy_descriptor[] = { 0x00, 0x01, 0x02 }; +TOOLCHAIN_ENABLE_CLANG_WARNING(TOOLCHAIN_WARNING_UNNEEDED_INTERNAL_DECLARATION) static struct webusb_bos_desc { struct usb_bos_descriptor bos;