Address oscompat warnings on Windows - #291
Merged
igoropaniuk merged 2 commits intoJul 21, 2026
Merged
Conversation
The Windows branch reads path[1] guarded only by short-circuit evaluation, which is correct at runtime but trips -Warray-bounds when the function is inlined with a string literal shorter than two bytes, as the oscompat unit tests do with "". It also passes a plain char to isalpha(), which is undefined behavior for negative values. Return early for the empty string, so the path[1] access is provably in bounds, and feed isalpha() an unsigned char. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
| snprintf(child, sizeof(child), "%s/%s", path, ent->d_name); | ||
| if (snprintf(child, sizeof(child), "%s/%s", path, | ||
| ent->d_name) >= (int)sizeof(child)) | ||
| continue; |
Contributor
Author
There was a problem hiding this comment.
right call, I've added the warning there
There was a problem hiding this comment.
overly-long
__func__ is generally discouraged in the kernel coding style. I think we should follow. Feel free to merge with that.
igoropaniuk
force-pushed
the
fix/windows-test-warnings
branch
from
July 21, 2026 12:27
625cadf to
0d7e5b4
Compare
quic-kdybcio
approved these changes
Jul 21, 2026
igoropaniuk
force-pushed
the
fix/windows-test-warnings
branch
from
July 21, 2026 12:52
0d7e5b4 to
1b7af6f
Compare
rmtree() concatenates the directory path and entry name into a PATH_MAX buffer without checking for truncation, which -Wformat- truncation flags on the Windows build where PATH_MAX is 260. A truncated path would also make the cleanup delete the wrong file in principle. Check the snprintf() result and skip entries that do not fit; using the return value also satisfies the warning. A skipped entry means the parent rmdir() fails with ENOTEMPTY and the workdir lingers, so report the skip on stderr instead of hiding it - the message names the entry, making a leftover workdir traceable to its cause. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
igoropaniuk
force-pushed
the
fix/windows-test-warnings
branch
from
July 21, 2026 12:58
1b7af6f to
fd0e86d
Compare
igoropaniuk
enabled auto-merge
July 21, 2026 12:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rmtree() concatenates the directory path and entry name into a
PATH_MAX buffer without checking for truncation, which -Wformat-
truncation flags on the Windows build where PATH_MAX is 260. A
truncated path would also make the cleanup delete the wrong file in
principle.
The Windows branch reads path[1] guarded only by short-circuit
evaluation, which is correct at runtime but trips -Warray-bounds when
the function is inlined with a string literal shorter than two bytes,
as the oscompat unit tests do with "". It also passes a plain char
to isalpha(), which is undefined behavior for negative values.