]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: prefer attribute.h in .c files
authorCollin Funk <collin.funk1@gmail.com>
Sat, 9 Aug 2025 03:32:18 +0000 (20:32 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Sat, 9 Aug 2025 03:49:29 +0000 (20:49 -0700)
* 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'.

cfg.mk
src/basenc.c

diff --git a/cfg.mk b/cfg.mk
index 2115b8441a3a96d8958ec4fc1a73c446283e5e97..4c634f663c04dba6c1e3090323d33580f66b5b63 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -304,6 +304,13 @@ sc_prohibit-gl-attributes:
        halt='Use _GL... attribute macros'                      \
          $(_sc_search_regexp)
 
+# Ensure that <attributes.h> 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 \*'                               \
index 3f550a71fa708b364cade11302c703d91bf7be2c..c445e6f41a36f6ae56fa12d65b200fbdb22d8493 100644 (file)
@@ -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);