Skip to content

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

Closed
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:fcntl_guard
Closed

gh-132915: Fix compiler warning in fcntlmodule.c#133254
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:fcntl_guard

Conversation

@vstinner

@vstinner vstinner commented May 1, 2025

Copy link
Copy Markdown
Member

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

vstinner commented May 1, 2025

Copy link
Copy Markdown
Member Author

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

vstinner commented May 1, 2025

Copy link
Copy Markdown
Member Author

cc @serhiy-storchaka

@vstinner

vstinner commented May 1, 2025

Copy link
Copy Markdown
Member Author

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
Copy Markdown
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