Skip to content

samples: http_server: Fix warning about integer name #93468

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/net/sockets/http_server/src/ws.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ int ws_echo_setup(int ws_socket, struct http_request_ctx *request_ctx, void *use
K_NO_WAIT);

if (IS_ENABLED(CONFIG_THREAD_NAME)) {
#define MAX_NAME_LEN sizeof("ws[xx]")
#define MAX_NAME_LEN (sizeof("ws[xxxxxxxxxx]"))
Copy link
Member

@cfriedt cfriedt Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@decsny - I don't want to be too nit-picky, so this isn't blocking by any means, but I think MAX_NAME_LEN should probably be defined in terms of CONFIG_THREAD_MAX_NAME_LEN. If you can respin, sure, but otherwise, I think we can probably merge anyway.

Below, N is the minimum expected number of digits to use for slots

Suggested change
#define MAX_NAME_LEN (sizeof("ws[xxxxxxxxxx]"))
BUILD_ASSERT(CONFIG_THREAD_MAX_NAME_LEN > (sizeof("ws[]") + N), "CONFIG_THREAD_MAX_NAME_LEN is too small");
#define MAX_NAME_LEN (CONFIG_THREAD_MAX_NAME_LEN - sizeof("ws[]"))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defer to @jukkar who had this opinion for how it is now

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest that we go with what we have now, we have used this pattern in other part of networking code too. If we want to have build asserts, we could introduce that to all places that have the name used.

char name[MAX_NAME_LEN];

snprintk(name, sizeof(name), "ws[%d]", slot);
Expand Down