Skip to content

Commit 7cbae7e

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/tools: Use array instead of string initializer
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 <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent b05d66c commit 7cbae7e

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

arch/s390/tools/gen_opcode_table.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ static int cmp_long_insn(const void *a, const void *b)
201201
return strcmp(((struct insn *)a)->name, ((struct insn *)b)->name);
202202
}
203203

204+
static void print_insn_name(const char *name)
205+
{
206+
size_t i, len;
207+
208+
len = strlen(name);
209+
printf("{");
210+
for (i = 0; i < len; i++)
211+
printf(" \'%c\',", name[i]);
212+
printf(" }");
213+
}
214+
204215
static void print_long_insn(struct gen_opcode *desc)
205216
{
206217
struct insn *insn;
@@ -223,7 +234,9 @@ static void print_long_insn(struct gen_opcode *desc)
223234
insn = &desc->insn[i];
224235
if (insn->name_len < 6)
225236
continue;
226-
printf("\t[LONG_INSN_%s] = \"%s\", \\\n", insn->upper, insn->name);
237+
printf("\t[LONG_INSN_%s] = ", insn->upper);
238+
print_insn_name(insn->name);
239+
printf(", \\\n");
227240
}
228241
printf("}\n\n");
229242
}
@@ -236,11 +249,13 @@ static void print_opcode(struct insn *insn, int nr)
236249
if (insn->type->byte != 0)
237250
opcode += 2;
238251
printf("\t[%4d] = { .opfrag = 0x%s, .format = INSTR_%s, ", nr, opcode, insn->format);
239-
if (insn->name_len < 6)
240-
printf(".name = \"%s\" ", insn->name);
241-
else
242-
printf(".offset = LONG_INSN_%s ", insn->upper);
243-
printf("}, \\\n");
252+
if (insn->name_len < 6) {
253+
printf(".name = ");
254+
print_insn_name(insn->name);
255+
} else {
256+
printf(".offset = LONG_INSN_%s", insn->upper);
257+
}
258+
printf(" }, \\\n");
244259
}
245260

246261
static void add_to_group(struct gen_opcode *desc, struct insn *insn, int offset)

0 commit comments

Comments
 (0)