Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ozdemo: fix GCC truncation warning #46

Closed
GitMensch opened this issue Dec 2, 2018 · 3 comments
Closed

ozdemo: fix GCC truncation warning #46

GitMensch opened this issue Dec 2, 2018 · 3 comments

Comments

@GitMensch
Copy link
Contributor

../demos/ozdemo.c: In function 'main':
../demos/ozdemo.c:355:17: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
                 strncpy(scrollbuf + i, message, msg_len);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../demos/ozdemo.c:345:27: note: length computed here
             int msg_len = strlen(message);
                           ^~~~~~~~~~~~~~~

proudly presented by

gcc.exe (Rev1, Built by MSYS2 project) 8.2.0

@wmcbrine
Copy link
Owner

wmcbrine commented Dec 4, 2018

The code is actually working as intended here. But, I wonder if it might be possible to rewrite it in a way that's more efficient, that will also kill the warning as a side effect...

@wmcbrine
Copy link
Owner

wmcbrine commented Dec 4, 2018

OK, did that.

@GitMensch
Copy link
Contributor Author

Arguably better code. Also fixes the warning and still works.

polluks pushed a commit to polluks/PDCurses that referenced this issue Aug 3, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants