n3322.pdf doesn't mention strnlen, but C2y will have strnlen, so strnlen(NULL, 0) will be valid. * lib/string.in.h: Use _GL_ATTRIBUTE_NONNULL_IF_NONZERO instead of _GL_ARG_NONNULL in strnlen. --- ChangeLog | 8 ++++++++ lib/string.in.h | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog index bb338f3ddb..4f62c653c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2026-07-31 Lasse Collin <[email protected]> + + string-h: Use _GL_ATTRIBUTE_NONNULL_IF_NONZERO in strnlen. + n3322.pdf doesn't mention strnlen, but C2y will have strnlen, + so strnlen(NULL, 0) will be valid. + * lib/string.in.h: Use _GL_ATTRIBUTE_NONNULL_IF_NONZERO instead of + _GL_ARG_NONNULL in strnlen. + 2026-07-31 Lasse Collin <[email protected]> string-h: Use _GL_ATTRIBUTE_NONNULL_IF_NONZERO in stpncpy. diff --git a/lib/string.in.h b/lib/string.in.h index 17ff019765..bc6e1e5f9e 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -949,13 +949,13 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " # endif _GL_FUNCDECL_RPL (strnlen, size_t, (char const *__s, size_t __maxlen), _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)); _GL_CXXALIAS_RPL (strnlen, size_t, (char const *__s, size_t __maxlen)); # else # if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__s, size_t __maxlen), _GL_ATTRIBUTE_PURE - _GL_ARG_NONNULL ((1))); + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2)); # endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__s, size_t __maxlen)); # endif -- 2.55.0
