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

net: l2: wifi: wifi_utils: Resolve build warning with strncpy function #67456

Merged
merged 1 commit into from
Jan 12, 2024
Merged

net: l2: wifi: wifi_utils: Resolve build warning with strncpy function #67456

merged 1 commit into from
Jan 12, 2024

Conversation

danieldegrasse
Copy link
Collaborator

GCC generates the following build warning from the strncpy call in "wifi_utils_parse_scan_bands":

warning: '__builtin_strncpy' output truncated before terminating nul copying as many bytes from a string as its length

To resolve this warning, pass the maximum length of the temporary parse_str buffer to strncpy. This also has the benefit of correctly null terminating parse_str, since we already verify the scan_bands_str is properly null terminated with the strlen() check in this function. We can therefore remove the line adding a null terminator to parse_str as well.

ARM GCC version 12.2.0 (Zephyr SDK 0.16.4) generates the following build
warning from the strncpy call in "wifi_utils_parse_scan_bands":

warning: '__builtin_strncpy' output truncated before terminating nul
copying as many bytes from a string as its length

To resolve this warning, pass the maximum length of the temporary
parse_str buffer to strncpy. This also has the benefit of correctly null
terminating parse_str, since we already verify the
scan_bands_str is properly null terminated with the strlen() check in
this function. We can therefore remove the line adding a null terminator
to parse_str as well.

Signed-off-by: Daniel DeGrasse <[email protected]>
@carlescufi carlescufi merged commit 76f547e into zephyrproject-rtos:main Jan 12, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants