Skip to content

Conversation

@thughes
Copy link
Contributor

@thughes thughes commented Mar 21, 2025

When building with clang, a few files are emitting warnings such as:

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[] = {
                     ^

However, this variable is needed at compile-time since it's referenced
via sizeof(). This appears to be the same as this clang bug:
llvm/llvm-project#25458.

This warning only started being emitted when I re-enabled the
-Wunused-function warning for clang.

@thughes thughes force-pushed the fix-unneeded-internal-declaration branch from 1c1b7ed to 8d1a397 Compare March 21, 2025 22:19
@thughes thughes changed the title tests: net: lib: http_server: Disable erroneous warning from clang Disable erroneous warning from clang Mar 21, 2025
@thughes
Copy link
Contributor Author

thughes commented Mar 21, 2025

We could also just disable the -Wunneeded-internal-declaration warning, though that has the risk of disabling legitimate warnings. Example.

Since this warning occurs in so few places, I propose we just disable the few places we get erroneous warnings.

@thughes thughes changed the title Disable erroneous warning from clang Disable erroneous warnings from clang Mar 21, 2025
@thughes thughes marked this pull request as ready for review March 24, 2025 17:13
@zephyrbot zephyrbot added area: mcumgr area: Toolchains Toolchains area: Networking area: HTTP HTTP client/server support area: USB Universal Serial Bus labels Mar 24, 2025
@thughes thughes force-pushed the fix-unneeded-internal-declaration branch from 8d1a397 to 3ea56a8 Compare March 24, 2025 17:30
@mrodgers-witekio
Copy link
Contributor

For the HTTP server test at least, I think the warning is genuine and we should probably verify that the response matches the expected string.

Adding:

zassert_mem_equal(buf, http1_header_capture_common_response, sizeof(http1_header_capture_common_response) - 1);

after test_read_data should fix it, I gave it a quick try and the tests all still pass.

@thughes
Copy link
Contributor Author

thughes commented Mar 24, 2025

Ah, thanks. I created #87585 to fix that. Let me know if you have ideas for the other tests.

@thughes thughes force-pushed the fix-unneeded-internal-declaration branch 2 times, most recently from d4b0575 to a8fef07 Compare March 24, 2025 18:33
thughes added 2 commits March 24, 2025 11:42
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 <tomhughes@chromium.org>
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 <tomhughes@chromium.org>
@thughes thughes force-pushed the fix-unneeded-internal-declaration branch from a8fef07 to 8db4009 Compare March 24, 2025 18:50
@thughes thughes closed this Mar 24, 2025
@thughes thughes deleted the fix-unneeded-internal-declaration branch March 24, 2025 20:38
@thughes
Copy link
Contributor Author

thughes commented Mar 24, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: HTTP HTTP client/server support area: mcumgr area: Networking area: Toolchains Toolchains area: USB Universal Serial Bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants