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

mkfs: Ignore strinop-truncation warning #313

Open
wants to merge 1 commit into
base: riscv
Choose a base branch
from

Conversation

alevy
Copy link

@alevy alevy commented Feb 21, 2025

mkfs uses the builtin strncpy, rather than kernel/strings.c, which, as of GCC-8, warns when n is the same size as the destination buffer, as it may not be able to add a NULL byte.

This is the desired behavior for xv6 directory entry names (which only require a NULL byte if they are shorter than DIRSIZ), but odd for normal uses of strncpy. So just ignore the warning to appease newer GCCs.

mkfs uses the builtin strncpy, rather than kernel/strings.c, which warns
when the `n` is the same size as the destination buffer, as it may not
be able to add a NULL byte. This is the desired behavior for directory
entry names (which only require a NULL byte if they are shorter than
DIRSIZ), so ignore the warning to appease newer GCCs.
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