]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
s390/tools: Use array instead of string initializer
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 24 Jan 2025 13:51:52 +0000 (14:51 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 28 Jan 2025 14:12:06 +0000 (15:12 +0100)
The in-kernel disassembler intentionally uses nun-null terminated
strings in order to keep the arrays which contain mnemonics as small
as possible. GCC 15 however warns about this:

./arch/s390/include/generated/asm/dis-defs.h:1662:71: error: initializer-string
 for array of ‘char’ is too long [-Werror=unterminated-string-initialization]
 1662 |         [1261] = { .opfrag = 0xea, .format = INSTR_SS_L0RDRD, .name = "unpka" }, \

Get rid of this warning by using array initializers.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/tools/gen_opcode_table.c

index a1bc02b29c81385ffacdd77d43f01c8ea5c8d675..7d76c417f83f52f38ebbe6184a501c3b29ab68cd 100644 (file)
@@ -201,6 +201,17 @@ static int cmp_long_insn(const void *a, const void *b)
        return strcmp(((struct insn *)a)->name, ((struct insn *)b)->name);
 }
 
+static void print_insn_name(const char *name)
+{
+       size_t i, len;
+
+       len = strlen(name);
+       printf("{");
+       for (i = 0; i < len; i++)
+               printf(" \'%c\',", name[i]);
+       printf(" }");
+}
+
 static void print_long_insn(struct gen_opcode *desc)
 {
        struct insn *insn;
@@ -223,7 +234,9 @@ static void print_long_insn(struct gen_opcode *desc)
                insn = &desc->insn[i];
                if (insn->name_len < 6)
                        continue;
-               printf("\t[LONG_INSN_%s] = \"%s\", \\\n", insn->upper, insn->name);
+               printf("\t[LONG_INSN_%s] = ", insn->upper);
+               print_insn_name(insn->name);
+               printf(", \\\n");
        }
        printf("}\n\n");
 }
@@ -236,11 +249,13 @@ static void print_opcode(struct insn *insn, int nr)
        if (insn->type->byte != 0)
                opcode += 2;
        printf("\t[%4d] = { .opfrag = 0x%s, .format = INSTR_%s, ", nr, opcode, insn->format);
-       if (insn->name_len < 6)
-               printf(".name = \"%s\" ", insn->name);
-       else
-               printf(".offset = LONG_INSN_%s ", insn->upper);
-       printf("}, \\\n");
+       if (insn->name_len < 6) {
+               printf(".name =  ");
+               print_insn_name(insn->name);
+       } else {
+               printf(".offset = LONG_INSN_%s", insn->upper);
+       }
+       printf(" }, \\\n");
 }
 
 static void add_to_group(struct gen_opcode *desc, struct insn *insn, int offset)