Skip to content

Silence strncpy warning for gcc 8#5840

Merged
zhangyangyu merged 1 commit into
python:masterfrom
siddhesh:master
Mar 6, 2018
Merged

Silence strncpy warning for gcc 8#5840
zhangyangyu merged 1 commit into
python:masterfrom
siddhesh:master

Conversation

@siddhesh

@siddhesh siddhesh commented Feb 23, 2018

Copy link
Copy Markdown
Contributor

The length in strncpy is one char too short and as a result it leads
to a build warning with gcc 8. bump up the length by one to copy the
NULL char.

@the-knights-who-say-ni

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

@siddhesh

Copy link
Copy Markdown
Contributor Author

I signed the CLA a couple of days ago, do I have to do something more to get the flag flipped?

@siddhesh siddhesh changed the title Copy NULL char in strncpy [skip issue][skip label] Copy NULL char in strncpy Mar 2, 2018
@zhangyangyu zhangyangyu changed the title [skip issue][skip label] Copy NULL char in strncpy Copy NULL char in strncpy Mar 6, 2018
@zhangyangyu

zhangyangyu commented Mar 6, 2018

Copy link
Copy Markdown
Member

I couldn't get the warning because Python applies -O:

/opt/bin/gcc -c -Wall -IInclude -I. Python/pystrtod.c
Python/pystrtod.c: In function ‘format_float_short’:
Python/pystrtod.c:1063:13: warning: ‘strncpy’ output truncated before terminating nul copying 3 bytes from a string of the same length [-Wstringop-truncation]
             strncpy(p, "ERR", 3);
             ^~~~~~~~~~~~~~~~~~~~
/opt/bin/gcc -c -O3 -Wall -IInclude -I. Python/pystrtod.c
/opt/bin/gcc -c -Og -Wall -IInclude -I. Python/pystrtod.c

But I think it's okay to just comment out the line.

The length in strncpy is one char too short and as a result it leads
to a build warning with gcc 8.  Comment out the strncpy since the
interpreter aborts immediately after anyway.
@siddhesh

siddhesh commented Mar 6, 2018

Copy link
Copy Markdown
Contributor Author

Done, commented out since the next line aborts anyway.

@zhangyangyu zhangyangyu merged commit efd2bac into python:master Mar 6, 2018
@bedevere-bot

Copy link
Copy Markdown

@zhangyangyu: Please replace # with GH- in the commit message next time. Thanks!

@zhangyangyu

Copy link
Copy Markdown
Member

Since Python's Makefile applies -O I only merge it with master branch. Thanks for your contribution @siddhesh :-)

@zhangyangyu zhangyangyu changed the title Copy NULL char in strncpy Silence strncpy warning for gcc 8 Mar 6, 2018
jo2y pushed a commit to jo2y/cpython that referenced this pull request Mar 23, 2018
The length in strncpy is one char too short and as a result it leads
to a build warning with gcc 8.  Comment out the strncpy since the
interpreter aborts immediately after anyway.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants