From c4e16f7e7c1492f34ba4544d435e387fa2d97cd7 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 2 Jun 2018 23:46:21 -0700 Subject: [PATCH 1/3] gcc: newer gcc trip on -Wstringop-truncation for valid uses of strncpy() strncpy() is correctly used to fill in a zero-*padded* (not zero-terminated) field in several places. Make gcc not complain about those uses. Signed-off-by: H. Peter Anvin --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index ff2d91df..e707158c 100644 --- a/configure.ac +++ b/configure.ac @@ -278,6 +278,9 @@ dnl Suppress format warning on Windows targets due to their PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format]) PA_ADD_CFLAGS([-Wc90-c99-compat]) PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long]) +dnl This is needed because we intentionally expect strncpy() to fill +dnl in a zero-padded (not zero-terminated) buffer in several backends +PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation]) dnl PA_ADD_CFLAGS([-Wwrite-strings]) PA_ARG_ENABLED([werror], [compile with -Werror to error out on any warning], From 7daa26f9ba3ca45813d16ce540564448c13b16fa Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 2 Jun 2018 23:48:16 -0700 Subject: [PATCH 2/3] gcc: fix mistakes discovered by recent gcc Recent versions of gcc issue a couple of warnings, which may be real bugs. Signed-off-by: H. Peter Anvin --- asm/listing.c | 2 +- asm/parser.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/asm/listing.c b/asm/listing.c index 40af8a62..6c459e13 100644 --- a/asm/listing.c +++ b/asm/listing.c @@ -199,7 +199,7 @@ static void list_address(int64_t offset, const char *brackets, static void list_output(const struct out_data *data) { - char q[20]; + char q[24]; uint64_t size = data->size; uint64_t offset = data->offset; const uint8_t *p = data->data; diff --git a/asm/parser.c b/asm/parser.c index 622259c8..40188410 100644 --- a/asm/parser.c +++ b/asm/parser.c @@ -436,6 +436,8 @@ insn *parse_line(int pass, char *buffer, insn *result) bool recover; int i; + nasm_static_assert(P_none == 0); + restart_parse: first = true; result->forw_ref = false; @@ -444,7 +446,6 @@ restart_parse: stdscan_set(buffer); i = stdscan(NULL, &tokval); - nasm_static_assert(P_none == 0); memset(result->prefixes, P_none, sizeof(result->prefixes)); result->times = 1; /* No TIMES either yet */ result->label = NULL; /* Assume no label */ From 675618c5dd670ea719d3c418e3d1d275b600b05f Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 15 Jun 2018 17:41:46 -0700 Subject: [PATCH 3/3] Makefile.in: remove duplicated $(ALL_CFLAGS) We really don't need every C compiler flag repeated twice. Signed-off-by: H. Peter Anvin --- Makefile.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index c9f8928a..9a8e2def 100644 --- a/Makefile.in +++ b/Makefile.in @@ -74,13 +74,13 @@ endif .PHONY: manpages nsis .c.$(O): - $(CC) -c $(ALL_CFLAGS) $(ALL_CFLAGS) -o $@ $< + $(CC) -c $(ALL_CFLAGS) -o $@ $< .c.s: - $(CC) -S $(ALL_CFLAGS) $(ALL_CFLAGS) -o $@ $< + $(CC) -S $(ALL_CFLAGS) -o $@ $< .c.i: - $(CC) -E $(ALL_CFLAGS) $(ALL_CFLAGS) -o $@ $< + $(CC) -E $(ALL_CFLAGS) -o $@ $< .txt.xml: $(ASCIIDOC) -b docbook -d manpage -o $@ $<