]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
termios: Suppress clang -Winitializer-overrider on ___cbaud_to_speed
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 20 Oct 2025 12:27:49 +0000 (09:27 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 21 Oct 2025 12:26:04 +0000 (09:26 -0300)
clang-18 and onwards issues:

../sysdeps/unix/sysv/linux/speed.c:71:23: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
   71 |       [_cbix(__B0)] = 0,
      |                       ^
../sysdeps/unix/sysv/linux/speed.c:70:34: note: previous initialization is here
   70 |       [0 ... _cbix(CBAUDMASK)] = -1,
[...]

The override is explicit used to support the same initialization on
multiple platforms (since the baud values differ on alpha and powerpc).

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
sysdeps/unix/sysv/linux/speed.c

index 4efb0ded59bafe02a6108abccc9e97ec5430eea2..3882d4ed329a336f05cdbdb8be6719f7740932fd 100644 (file)
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <termios_internals.h>
+#include <libc-diag.h>
 
 /* Conversions between legacy c_cflag fields and actual baud rates */
 
 speed_t
 ___cbaud_to_speed (tcflag_t c_cflag, speed_t other)
 {
+  /* The override is explicit used to support the same initialization on
+     multiple platforms.  */
+  DIAG_PUSH_NEEDS_COMMENT_CLANG;
+  DIAG_IGNORE_NEEDS_COMMENT_CLANG (18, "-Winitializer-overrides");
   static const speed_t cbaudix_to_speed [] =
     {
       [0 ... _cbix(CBAUDMASK)] = -1,
@@ -124,6 +129,7 @@ ___cbaud_to_speed (tcflag_t c_cflag, speed_t other)
       [_cbix(__B4000000)] = 4000000,
 #endif
     };
+  DIAG_POP_NEEDS_COMMENT_CLANG;
   speed_t speed;
 
   if (c_cflag & (tcflag_t)(~CBAUDMASK))