Silence compiler warning for strncat.#77
Open
ckujau wants to merge 1 commit intocorecode:masterfrom
ckujau:local
Open
Silence compiler warning for strncat.#77ckujau wants to merge 1 commit intocorecode:masterfrom ckujau:local
ckujau wants to merge 1 commit intocorecode:masterfrom
ckujau:local
Conversation
-----------------------------------------------------------------------
In file included from /usr/include/string.h:495,
from net.c:57:
In function ‘strncat’,
inlined from ‘read_remote.part.0’ at net.c:168:4:
/usr/include/bits/string_fortified.h:136:10: warning: ‘__builtin___strncat_chk’ output \
may be truncated copying between 0 and 1023 bytes from a string of length 2047 [-Wstringop-truncation]
136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-----------------------------------------------------------------------
Similar reports can be found on the interwebs:
* Fix FTBFS with GCC-9 (Closes: #925677)
https://salsa.debian.org/fcoe-team/fcoe-utils/-/blob/master/debian/patches/fix-gcc-warnings.patch
* gcc warns strncat() as terminating nul is not copied while it need not
https://bugzilla.redhat.com/show_bug.cgi?id=1798636
This patch sheepishly attempts to follow these examples and the warning is now no
longer present. The program compiles but it may not be the right thing to do, please
verify!
net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Signed-off-by: Christian Kujau <[email protected]>
Owner
|
I think we should use |
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.
When compiling with newer GCC versions the following warning is emitted:
In file included from /usr/include/string.h:495,
from net.c:57:
In function ‘strncat’,
inlined from ‘read_remote.part.0’ at net.c:168:4:
/usr/include/bits/string_fortified.h:136:10: warning: ‘__builtin___strncat_chk’ output
may be truncated copying between 0 and 1023 bytes from a string of length 2047 [-Wstringop-truncation]
136 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Similar reports can be found on the interwebs:
Fix FTBFS with GCC-9 (Closes: #925677)
https://salsa.debian.org/fcoe-team/fcoe-utils/-/blob/master/debian/patches/fix-gcc-warnings.patch
gcc warns strncat() as terminating nul is not copied while it need not
https://bugzilla.redhat.com/show_bug.cgi?id=1798636
This patch sheepishly attempts to follow these examples and the warning is now no
longer present. The program compiles but it may not be the right thing to do, please
verify!
net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)