From d053d639f00c58122ac0e3fe3a08aa8dc2a08ce6 Mon Sep 17 00:00:00 2001 From: Vasily Gorbik Date: Fri, 29 Jun 2018 17:32:09 +0200 Subject: [PATCH] s390/tools: fix gcc 8 stringop-truncation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Replace strncpy which has been used to copy a substring into buf without NUL-termination with memcpy to avoid the following gcc 8 warnings: arch/s390/tools/gen_opcode_table.c: In function ‘add_to_group.isra.4’: arch/s390/tools/gen_opcode_table.c:260:2: warning: ‘strncpy’ output may be truncated copying 2 bytes from a string of length 19 [-Wstringop-truncation] strncpy(group->opcode, insn->opcode, 2); In function ‘print_opcode_table’, inlined from ‘main’ at arch/s390/tools/gen_opcode_table.c:333:2: arch/s390/tools/gen_opcode_table.c:286:4: warning: ‘strncpy’ output may be truncated copying 2 bytes from a string of length 19 [-Wstringop-truncation] strncpy(opcode, insn->opcode, 2); Reviewed-by: Heiko Carstens Signed-off-by: Vasily Gorbik Signed-off-by: Martin Schwidefsky --- arch/s390/tools/gen_opcode_table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/tools/gen_opcode_table.c b/arch/s390/tools/gen_opcode_table.c index 259aa0680d1a..a1bc02b29c81 100644 --- a/arch/s390/tools/gen_opcode_table.c +++ b/arch/s390/tools/gen_opcode_table.c @@ -257,7 +257,7 @@ static void add_to_group(struct gen_opcode *desc, struct insn *insn, int offset) if (!desc->group) exit(EXIT_FAILURE); group = &desc->group[desc->nr_groups - 1]; - strncpy(group->opcode, insn->opcode, 2); + memcpy(group->opcode, insn->opcode, 2); group->type = insn->type; group->offset = offset; group->count = 1; @@ -283,7 +283,7 @@ static void print_opcode_table(struct gen_opcode *desc) continue; add_to_group(desc, insn, offset); if (strncmp(opcode, insn->opcode, 2)) { - strncpy(opcode, insn->opcode, 2); + memcpy(opcode, insn->opcode, 2); printf("\t/* %.2s */ \\\n", opcode); } print_opcode(insn, offset); -- 2.11.0