Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable erroneous warnings from clang #87498

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thughes
Copy link
Contributor

@thughes thughes commented Mar 21, 2025

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

tests/net/lib/http_server/core/src/main.c:1400:19: error: variable
'http1_header_capture_common_response' is not needed and will not be
emitted [-Werror,-Wunneeded-internal-declaration]
static const char http1_header_capture_common_response[]
                  ^                             = "HTTP/1.1 200\r\n"

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 added 3 commits March 21, 2025 15:12
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 <[email protected]>
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 <[email protected]>
The warning emitted is:

tests/net/lib/http_server/core/src/main.c:1400:19: error: variable
'http1_header_capture_common_response' is not needed and will not be
emitted [-Werror,-Wunneeded-internal-declaration]
static const char http1_header_capture_common_response[]
                  ^                             = "HTTP/1.1 200\r\n"

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.

Signed-off-by: Tom Hughes <[email protected]>
@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 prose 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant