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

Silence strncpy warning for gcc 8 #5840

Merged
merged 1 commit into from
Mar 6, 2018
Merged

Silence strncpy warning for gcc 8 #5840

merged 1 commit into from
Mar 6, 2018

Conversation

siddhesh
Copy link
Contributor

@siddhesh siddhesh commented Feb 23, 2018

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

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
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
Copy link
Member

zhangyangyu commented Mar 6, 2018

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
Copy link
Contributor Author

siddhesh commented Mar 6, 2018

Done, commented out since the next line aborts anyway.

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

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

@zhangyangyu
Copy link
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