]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
backends: allocate enough stace for null terminator
authorSergei Trofimovich <slyich@gmail.com>
Wed, 17 Jul 2024 22:03:34 +0000 (23:03 +0100)
committerMark Wielaard <mark@klomp.org>
Thu, 18 Jul 2024 16:43:33 +0000 (18:43 +0200)
`gcc-15` added a new warning in https://gcc.gnu.org/PR115185:

    i386_regs.c:88:11: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization]
       88 |           "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip"
          |           ^~~~

`elfutils` does not need to store '\0'. We could either initialize the
arrays with individual bytes or allocate extra byte for null.

This change initializes the array bytewise.

* backends/i386_regs.c (i386_register_info): Initialize the
array bytewise to fix gcc-15 warning.
* backends/x86_64_regs.c (x86_64_register_info): Ditto.

Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
backends/i386_regs.c
backends/x86_64_regs.c

index 7ec93bb9fc131d10c55fcd5859b84f6478e1f4a4..ead55ef7f9314e2c4b695477b761c9bc70f1b32e 100644 (file)
@@ -85,7 +85,15 @@ i386_register_info (Ebl *ebl __attribute__ ((unused)),
     {
       static const char baseregs[][2] =
        {
-         "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip"
+         {'a', 'x'},
+         {'c', 'x'},
+         {'d', 'x'},
+         {'b', 'x'},
+         {'s', 'p'},
+         {'b', 'p'},
+         {'s', 'i'},
+         {'d', 'i'},
+         {'i', 'p'},
        };
 
     case 4:
index ef987daf43f01187c468d29e4d412ecafdcb2878..dab8f27ffad7b940683d7b24d0190663ed973291 100644 (file)
@@ -82,7 +82,14 @@ x86_64_register_info (Ebl *ebl __attribute__ ((unused)),
     {
       static const char baseregs[][2] =
        {
-         "ax", "dx", "cx", "bx", "si", "di", "bp", "sp"
+         {'a', 'x'},
+         {'d', 'x'},
+         {'c', 'x'},
+         {'b', 'x'},
+         {'s', 'i'},
+         {'d', 'i'},
+         {'b', 'p'},
+         {'s', 'p'},
        };
 
     case 6 ... 7: