Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jremus@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

authored by

Heiko Carstens and committed by
Alexander Gordeev
7cbae7ea b05d66c8

+21 -6
+21 -6
arch/s390/tools/gen_opcode_table.c
··· 201 201 return strcmp(((struct insn *)a)->name, ((struct insn *)b)->name); 202 202 } 203 203 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 + 204 215 static void print_long_insn(struct gen_opcode *desc) 205 216 { 206 217 struct insn *insn; ··· 234 223 insn = &desc->insn[i]; 235 224 if (insn->name_len < 6) 236 225 continue; 237 - printf("\t[LONG_INSN_%s] = \"%s\", \\\n", insn->upper, insn->name); 226 + printf("\t[LONG_INSN_%s] = ", insn->upper); 227 + print_insn_name(insn->name); 228 + printf(", \\\n"); 238 229 } 239 230 printf("}\n\n"); 240 231 } ··· 249 236 if (insn->type->byte != 0) 250 237 opcode += 2; 251 238 printf("\t[%4d] = { .opfrag = 0x%s, .format = INSTR_%s, ", nr, opcode, insn->format); 252 - if (insn->name_len < 6) 253 - printf(".name = \"%s\" ", insn->name); 254 - else 255 - printf(".offset = LONG_INSN_%s ", insn->upper); 256 - printf("}, \\\n"); 239 + if (insn->name_len < 6) { 240 + printf(".name = "); 241 + print_insn_name(insn->name); 242 + } else { 243 + printf(".offset = LONG_INSN_%s", insn->upper); 244 + } 245 + printf(" }, \\\n"); 257 246 } 258 247 259 248 static void add_to_group(struct gen_opcode *desc, struct insn *insn, int offset)