Skip to content

GCC 15: Fix unterminated-string-initialization #17244

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

Merged
merged 1 commit into from
Apr 16, 2025

Conversation

tonyhutter
Copy link
Contributor

Motivation and Context

Build ZFS on Fedora 42 (GCC 15). Closes: #17242

Description

Fix build errors on Fedora 42 like:

module/zcommon/zfs_valstr.c:193:16: error: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (3 chars into 2 available)

GCC 15 is flagging arrays that look like they're strings, but have no space for the ending NULL terminator. The arrays in zpool_vdev_os.c and zfs_valstr.c look like strings but are not meant to be NULL terminated, which is why they are getting flagged.

How Has This Been Tested?

Successfully built on Fedora 42.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Fix build errors on Fedora 42 like:

  module/zcommon/zfs_valstr.c:193:16: error: initializer-string for
  array of 'char' truncates NUL terminator but destination lacks
  'nonstring' attribute (3 chars into 2 available)

The arrays in zpool_vdev_os.c and zfs_valstr.c don't need to be
NULL terminated, but we do so to make GCC happy.

Closes: openzfs#17242
Signed-off-by: Tony Hutter <[email protected]>
@tonyhutter
Copy link
Contributor Author

tonyhutter commented Apr 16, 2025

I ended up ditching __attribute__((nonstring)) and just expanded the arrays. CI is happy now.

@tonyhutter tonyhutter merged commit 155847c into openzfs:master Apr 16, 2025
20 of 23 checks passed
tonyhutter added a commit to tonyhutter/zfs that referenced this pull request Apr 16, 2025
Fix build errors on Fedora 42 like:

  module/zcommon/zfs_valstr.c:193:16: error: initializer-string for
  array of 'char' truncates NUL terminator but destination lacks
  'nonstring' attribute (3 chars into 2 available)

The arrays in zpool_vdev_os.c and zfs_valstr.c don't need to be
NULL terminated, but we do so to make GCC happy.

Closes: openzfs#17242

Signed-off-by: Tony Hutter <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Fedora 42
3 participants