]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: ist: do not put a cast in an array declaration
authorWilly Tarreau <w@1wt.eu>
Wed, 24 May 2023 19:27:39 +0000 (21:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 May 2023 19:27:39 +0000 (21:27 +0200)
TCC is upset by the declaration looking like:

  const unsigned char ist_lc[256] __attribute__((weak)) = ((const unsigned char[256]){ ... });

It was written like this because it's expanded from the _IST_LC macro
but it's never used as-is, it's only used from ist_lc, which should be
the one containing the cast so that the macro only contains the list of
bytes that can be used in both places. And this assigns more consistent
roles to the lower and upper case macro/variable now, one is typed and
the other one not. No backport is needed.

include/import/ist.h

index 978fb3c7224759dfc130cd5f3bb898e069b3b014..1ac23c815dc9294fdfd710e4ae05f1c06121ea29 100644 (file)
@@ -38,7 +38,7 @@
 #endif
 
 /* ASCII to lower case conversion table */
-#define _IST_LC ((const unsigned char[256]){            \
+#define _IST_LC {                                       \
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, \
        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, \
        0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, \
        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, \
        0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, \
-})
+}
 
 /* ASCII to upper case conversion table */
-#define _IST_UC ((const unsigned char[256]){            \
+#define _IST_UC {                                       \
        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, \
        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, \
        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, \
        0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, \
        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, \
        0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, \
-})
+}
 
 #ifdef USE_OBSOLETE_LINKER
 /* some old linkers and some non-ELF platforms have issues with the weak
  * attribute so we turn these arrays to literals there.
  */
-#define ist_lc _IST_LC
-#define ist_uc _IST_UC
+#define ist_lc ((const unsigned char[256])_IST_LC)
+#define ist_uc ((const unsigned char[256])_IST_UC)
 #else
 const unsigned char ist_lc[256] __attribute__((weak)) = _IST_LC;
 const unsigned char ist_uc[256] __attribute__((weak)) = _IST_UC;