Skip to content

Address oscompat warnings on Windows - #291

Merged
igoropaniuk merged 2 commits into
linux-msm:masterfrom
igoropaniuk:fix/windows-test-warnings
Jul 21, 2026
Merged

Address oscompat warnings on Windows#291
igoropaniuk merged 2 commits into
linux-msm:masterfrom
igoropaniuk:fix/windows-test-warnings

Conversation

@igoropaniuk

Copy link
Copy Markdown
Contributor
  • 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.

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>
@igoropaniuk
igoropaniuk requested a review from a team as a code owner July 18, 2026 07:20
Comment thread tests/test_oscompat.c
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we warn here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right call, I've added the warning there

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

overly-long

__func__ is generally discouraged in the kernel coding style. I think we should follow. Feel free to merge with that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks!

@igoropaniuk
igoropaniuk force-pushed the fix/windows-test-warnings branch from 625cadf to 0d7e5b4 Compare July 21, 2026 12:27
@igoropaniuk
igoropaniuk force-pushed the fix/windows-test-warnings branch from 0d7e5b4 to 1b7af6f Compare July 21, 2026 12:52
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
igoropaniuk force-pushed the fix/windows-test-warnings branch from 1b7af6f to fd0e86d Compare July 21, 2026 12:58
@igoropaniuk
igoropaniuk enabled auto-merge July 21, 2026 12:59
@igoropaniuk
igoropaniuk merged commit 7c5a28d into linux-msm:master Jul 21, 2026
14 checks passed
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.

2 participants