From: Bruno Haible Date: Sat, 10 May 2025 15:12:28 +0000 (+0200) Subject: string-desc, xstring-desc: Avoid GCC attributes in function definitions. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ae4881d4c360c8675d5e2c397c193bc81660c3a;p=thirdparty%2Fgnulib.git string-desc, xstring-desc: Avoid GCC attributes in function definitions. Reported by Collin Funk in . * lib/attribute.h: Clarify the allowed positions of attributes in function definitions. * lib/string-desc.h (_sd_char_at): Add a declaration, to hold the gcc attrribute. * lib/xstring-desc.h (_xsd_c): Likewise. --- diff --git a/ChangeLog b/ChangeLog index c71bacdda9..2d7696a717 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2025-05-10 Bruno Haible + + string-desc, xstring-desc: Avoid GCC attributes in function definitions. + Reported by Collin Funk in + . + * lib/attribute.h: Clarify the allowed positions of attributes in + function definitions. + * lib/string-desc.h (_sd_char_at): Add a declaration, to hold the + gcc attrribute. + * lib/xstring-desc.h (_xsd_c): Likewise. + 2025-05-10 Bruno Haible string-desc: Improve a declaration. diff --git a/lib/attribute.h b/lib/attribute.h index ae7bbe8e2c..c85412d90a 100644 --- a/lib/attribute.h +++ b/lib/attribute.h @@ -50,8 +50,9 @@ - In a function declaration/definition with a storage-class specifier: between the storage-class specifier and the return type. - - Or after the parameter list, - ∙ but after ATTRIBUTE_NOTHROW if present. + - Or, in a function declaration: + after the parameter list, + ∙ but after ATTRIBUTE_NOTHROW if present. In other declarations, such as variable declarations: diff --git a/lib/string-desc.h b/lib/string-desc.h index 8bd6691914..db6925d0d8 100644 --- a/lib/string-desc.h +++ b/lib/string-desc.h @@ -319,7 +319,9 @@ sd_length (string_desc_t s) }) GL_STRING_DESC_INLINE char _sd_char_at (idx_t s_nbytes, const char *s_data, idx_t i) - _GL_ATTRIBUTE_NONNULL ((2)) + _GL_ATTRIBUTE_NONNULL ((2)); +GL_STRING_DESC_INLINE char +_sd_char_at (idx_t s_nbytes, const char *s_data, idx_t i) { if (!(i >= 0 && i < s_nbytes)) /* Invalid argument. */ diff --git a/lib/xstring-desc.h b/lib/xstring-desc.h index 216865a267..17ea35e357 100644 --- a/lib/xstring-desc.h +++ b/lib/xstring-desc.h @@ -100,7 +100,11 @@ GL_XSTRING_DESC_INLINE _GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_RETURNS_NONNULL char * _xsd_c (idx_t s_nbytes, const char *s_data) - _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 1) + _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 1); +GL_XSTRING_DESC_INLINE +_GL_ATTRIBUTE_DEALLOC_FREE _GL_ATTRIBUTE_RETURNS_NONNULL +char * +_xsd_c (idx_t s_nbytes, const char *s_data) { char *result = _sd_c (s_nbytes, s_data); if (result == NULL)