From: Collin Funk Date: Sat, 9 Aug 2025 03:32:18 +0000 (-0700) Subject: maint: prefer attribute.h in .c files X-Git-Tag: v9.8~116 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=13202995bafc11fc7c881bcdae4c6f10da78c83b;p=thirdparty%2Fcoreutils.git maint: prefer attribute.h in .c files * src/basenc.c (base16_encode, z85_encoding, do_decode): Use ATTRIBUTE_NONSTRING instead of ATTRIBUTE_NONSTRING. * src/basenc.c (sc_prohibit-_gl-attributes): New rule for 'make syntax-check'. --- diff --git a/cfg.mk b/cfg.mk index 2115b8441a..4c634f663c 100644 --- a/cfg.mk +++ b/cfg.mk @@ -304,6 +304,13 @@ sc_prohibit-gl-attributes: halt='Use _GL... attribute macros' \ $(_sc_search_regexp) +# Ensure that macros are used in .c files. +sc_prohibit-_gl-attributes: + @prohibit='_GL_ATTRIBUTE' \ + in_vc_files='\.c$$' \ + halt='Use ATTRIBUTE_... instead of _GL_ATTRIBUTE_...' \ + $(_sc_search_regexp) + # Prefer the const declaration form, with const following the type sc_prohibit-const-char: @prohibit='const char \*' \ diff --git a/src/basenc.c b/src/basenc.c index 3f550a71fa..c445e6f41a 100644 --- a/src/basenc.c +++ b/src/basenc.c @@ -626,7 +626,7 @@ static void base16_encode (char const *restrict in, idx_t inlen, char *restrict out, idx_t outlen) { - static const char base16[16] _GL_ATTRIBUTE_NONSTRING = "0123456789ABCDEF"; + static const char base16[16] ATTRIBUTE_NONSTRING = "0123456789ABCDEF"; while (inlen && outlen) { @@ -711,7 +711,7 @@ isuz85 (unsigned char ch) return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr; } -static char const z85_encoding[85] _GL_ATTRIBUTE_NONSTRING = +static char const z85_encoding[85] ATTRIBUTE_NONSTRING = "0123456789" "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" @@ -1136,7 +1136,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage) idx_t sum; struct base_decode_context ctx; - char padbuf[8] _GL_ATTRIBUTE_NONSTRING = "========"; + char padbuf[8] ATTRIBUTE_NONSTRING = "========"; inbuf = xmalloc (BASE_LENGTH (DEC_BLOCKSIZE)); outbuf = xmalloc (DEC_BLOCKSIZE);