Skip to content

gh-132915: Fix compiler warning in fcntlmodule.c #133254

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

Closed
wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented May 1, 2025

Fix the warning:

Modules/fcntlmodule.c:27:36: warning: initializer-string for
array of 'char' truncates NUL terminator but destination lacks
'nonstring' attribute (9 chars into 8 available)
[-Wunterminated-string-initialization]
static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";

Fix the warning:

    Modules/fcntlmodule.c:27:36: warning: initializer-string for
    array of 'char' truncates NUL terminator but destination lacks
    'nonstring' attribute (9 chars into 8 available)
    [-Wunterminated-string-initialization]
    static const char guard[GUARDSZ] = "\x00\xfa\x69\xc4\x67\xa3\x6c\x58";
@vstinner
Copy link
Member Author

vstinner commented May 1, 2025

It seems to be a new warning of GCC 15 (my GCC version on Fedora 42).

destination lacks 'nonstring' attribute

I prefer to add an unused null byte at the end instead of adding a new macro for this new attribute:
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-nonstring-variable-attribute

@vstinner
Copy link
Member Author

vstinner commented May 1, 2025

cc @serhiy-storchaka

@vstinner
Copy link
Member Author

vstinner commented May 1, 2025

Oh, another function needs the attribute. So I decided to add the attribute instead :-(

@vstinner vstinner closed this May 1, 2025
@serhiy-storchaka
Copy link
Member

We could just use array initializer: {0, 250, 105, 196, 103, 163, 108, 88}.

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.

2 participants