From: Adhemerval Zanella Date: Fri, 17 Oct 2025 19:12:50 +0000 (-0300) Subject: iconvdata: Fix clang -Wstring-plus-int clang warning X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea3f174e8508b7427fb39684331425492018b8fe;p=thirdparty%2Fglibc.git iconvdata: Fix clang -Wstring-plus-int clang warning clang issues an warning adding '{unsigned} int' to a string does not append to the string. Use array indexes instead of string addition (it is simpler than add a supress warning). Reviewed-by: Sam James --- diff --git a/iconvdata/gbk.c b/iconvdata/gbk.c index ac77c891ce..54ddcc079c 100644 --- a/iconvdata/gbk.c +++ b/iconvdata/gbk.c @@ -13286,7 +13286,7 @@ static const char __gbk_from_ucs4_tab12[][2] = cp = "\xa8\xc0"; \ break; \ case 0x2c7 ... 0x2cb: \ - cp = "\xa1\xa6\0\0\0\0\0\0\xa1\xa5\0\0\xa8\x40\0\0\xa8\x41" + ((ch - 0x2c7) * 4); \ + cp = &"\xa1\xa6\0\0\0\0\0\0\xa1\xa5\0\0\xa8\x40\0\0\xa8\x41"[(ch - 0x2c7) * 4]; \ break; \ case 0x2d9: \ cp = "\xa8\x42"; \ @@ -13330,7 +13330,7 @@ static const char __gbk_from_ucs4_tab12[][2] = buf[1] = '\x80' + (ch - 0x2588); \ break; \ case 0x2593 ... 0x2595: \ - cp = "\xa8\x88\0\0\xa8\x89\0\0\xa8\x8a" + ((ch - 0x2593) * 4); \ + cp = &"\xa8\x88\0\0\xa8\x89\0\0\xa8\x8a"[(ch - 0x2593) * 4]; \ break; \ case 0x25a0: \ cp = "\xa1\xf6"; \ @@ -13461,7 +13461,7 @@ static const char __gbk_from_ucs4_tab12[][2] = cp = __gbk_from_ucs4_tab12[ch - 0xff01]; \ break; \ case 0xffe0 ... 0xffe5: \ - cp = "\xa1\xe9\0\0\xa1\xea\0\0\xa9\x56\0\0\xa3\xfe\0\0\xa9\x57\0\0\xa3\xa4" + ((ch - 0xffe0) * 4); \ + cp = &"\xa1\xe9\0\0\xa1\xea\0\0\xa9\x56\0\0\xa3\xfe\0\0\xa9\x57\0\0\xa3\xa4" [(ch - 0xffe0) * 4]; \ break; \ default: \ UNICODE_TAG_HANDLER (ch, 4); \ diff --git a/iconvdata/iso-2022-cn-ext.c b/iconvdata/iso-2022-cn-ext.c index 2afa5e3b4d..ade40c745e 100644 --- a/iconvdata/iso-2022-cn-ext.c +++ b/iconvdata/iso-2022-cn-ext.c @@ -562,7 +562,7 @@ DIAG_IGNORE_Os_NEEDS_COMMENT_GCC (5, "-Wmaybe-uninitialized"); } \ \ assert (used >= 1 && used <= 4); \ - escseq = ")A\0\0)G)E" + (used - 1) * 2; \ + escseq = &")A\0\0)G)E"[(used - 1) * 2]; \ *outptr++ = ESC; \ *outptr++ = '$'; \ *outptr++ = *escseq++; \ @@ -600,7 +600,7 @@ DIAG_IGNORE_Os_NEEDS_COMMENT_GCC (5, "-Wmaybe-uninitialized"); } \ \ assert ((used >> 5) >= 3 && (used >> 5) <= 7); \ - escseq = "+I+J+K+L+M" + ((used >> 5) - 3) * 2; \ + escseq = &"+I+J+K+L+M"[((used >> 5) - 3) * 2]; \ *outptr++ = ESC; \ *outptr++ = '$'; \ *outptr++ = *escseq++; \ diff --git a/iconvdata/iso-2022-cn.c b/iconvdata/iso-2022-cn.c index 0b81714256..7fe4b36f27 100644 --- a/iconvdata/iso-2022-cn.c +++ b/iconvdata/iso-2022-cn.c @@ -326,7 +326,7 @@ enum } \ \ assert ((used >> 3) >= 1 && (used >> 3) <= 3); \ - escseq = ")A)G*H" + ((used >> 3) - 1) * 2; \ + escseq = &")A)G*H"[((used >> 3) - 1) * 2]; \ *outptr++ = ESC; \ *outptr++ = '$'; \ *outptr++ = *escseq++; \