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

We know how much to copy, so use memcpy #89

Merged
merged 1 commit into from Jan 23, 2024

Conversation

thomas3494
Copy link

Silence warnings

Copy link
Member

@sbscholz sbscholz left a comment

Choose a reason for hiding this comment

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

so why did the C compiler complain about the old code? it seems virtually identical?!

@thomas3494
Copy link
Author

The behaviour is identical. The warning given was 'strncpy' specified bound depends on the length of the source argument.

The man page says

char *strncpy(char dst[restrict .sz], const char *restrict src,
size_t sz);

so it should be the size of the destination. I think it complains because it is not useful to use strncpy in this case.

Copy link
Member

@sbscholz sbscholz left a comment

Choose a reason for hiding this comment

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

seems both fine but in case the compiler prefers the latter, so be it :-)

@sbscholz sbscholz merged commit 5d1aa62 into SacBase:master Jan 23, 2024
2 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.

None yet

2 participants