Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Nick Clifton <nickc@redhat.com>, Pedro Alves <palves@redhat.com>
Cc: Binutils <binutils@sourceware.org>, GDB <gdb-patches@sourceware.org>
Subject: Re: [PATCH 3/3] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8
Date: Mon, 04 Jun 2018 16:58:00 -0000	[thread overview]
Message-ID: <CAMe9rOo24=MWapo0tU5cSJKRULnV_oLq1djxXEZ5chXe6DeZNQ@mail.gmail.com> (raw)
In-Reply-To: <ac96fdc5-62f0-1bfa-5acf-8ca0f9389659@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

On Fri, Jun 1, 2018 at 12:59 AM, Nick Clifton <nickc@redhat.com> wrote:
> Hi H.J.
>
>>       PR binutils/23146
>>       * bfd-in.h: Include "diagnostics.h".
>>       * bfd-in2.h: Regenerated.
>>       * elf32-arm.c (elf32_arm_nabi_write_core_note): Use
>>       DIAGNOSTIC_PUSH, DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION and
>>       DIAGNOSTIC_POP to silence GCC 8 warnings with
>>       -Wstringop-truncation.
>>       * elf32-ppc.c (ppc_elf_write_core_note): Likewse.
>>       * elf32-s390.c (elf_s390_write_core_note): Likewse.
>>       * elf64-ppc.c (ppc64_elf_write_core_note): Likewse.
>>       * elf64-s390.c (elf_s390_write_core_note): Likewse.
>>       * elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewse.
>
> Approved - please apply.
>

This is the patch I am checking in.

-- 
H.J.

[-- Attachment #2: 0001-Use-DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION-to-silence.patch --]
[-- Type: text/x-patch, Size: 6792 bytes --]

From 30a2bf66aa5b1a22ea14cbc5eb10d12cae5657c1 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Mon, 4 Jun 2018 09:48:28 -0700
Subject: [PATCH] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8.1

GCC 8.1 warns about destination size with -Wstringop-truncation:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643

Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence it.

bfd/

	PR binutils/23146
	* bfd-in.h: Include "diagnostics.h".
	* bfd-in2.h: Regenerated.
	* elf32-arm.c (elf32_arm_nabi_write_core_note): Use
	DIAGNOSTIC_PUSH, DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION and
	DIAGNOSTIC_POP to silence GCC 8.1 warnings with
	-Wstringop-truncation.
	* elf32-ppc.c (ppc_elf_write_core_note): Likewse.
	* elf32-s390.c (elf_s390_write_core_note): Likewse.
	* elf64-ppc.c (ppc64_elf_write_core_note): Likewse.
	* elf64-s390.c (elf_s390_write_core_note): Likewse.
	* elfxx-aarch64.c (_bfd_aarch64_elf_write_core_note): Likewse.

include/

	* diagnostics.h (DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION): Always
	define for GCC.
---
 bfd/bfd-in.h          | 1 +
 bfd/bfd-in2.h         | 1 +
 bfd/elf32-arm.c       | 9 +++++++++
 bfd/elf32-ppc.c       | 9 +++++++++
 bfd/elf32-s390.c      | 9 +++++++++
 bfd/elf64-ppc.c       | 9 +++++++++
 bfd/elf64-s390.c      | 9 +++++++++
 bfd/elfxx-aarch64.c   | 9 +++++++++
 include/diagnostics.h | 4 +---
 9 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 481587e458..1d477c3f5f 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -34,6 +34,7 @@ extern "C" {
 
 #include "ansidecl.h"
 #include "symcat.h"
+#include "diagnostics.h"
 #include <stdarg.h>
 #include <sys/stat.h>
 
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index ef62f31953..65735f026e 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -41,6 +41,7 @@ extern "C" {
 
 #include "ansidecl.h"
 #include "symcat.h"
+#include "diagnostics.h"
 #include <stdarg.h>
 #include <sys/stat.h>
 
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index dbfd838fbe..870111b5ed 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2174,7 +2174,16 @@ elf32_arm_nabi_write_core_note (bfd *abfd, char *buf, int *bufsiz,
 	va_start (ap, note_type);
 	memset (data, 0, sizeof (data));
 	strncpy (data + 28, va_arg (ap, const char *), 16);
+	DIAGNOSTIC_PUSH;
+	/* GCC 8.1 warns about 80 equals destination size with
+	   -Wstringop-truncation:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643
+	 */
+#if GCC_VERSION == 8001
+	DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION;
+#endif
 	strncpy (data + 44, va_arg (ap, const char *), 80);
+	DIAGNOSTIC_POP;
 	va_end (ap);
 
 	return elfcore_write_note (abfd, buf, bufsiz,
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 3482baca20..ea8dbed981 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -2411,7 +2411,16 @@ ppc_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type, ...)
 	va_start (ap, note_type);
 	memset (data, 0, sizeof (data));
 	strncpy (data + 32, va_arg (ap, const char *), 16);
+	DIAGNOSTIC_PUSH;
+	/* GCC 8.1 warns about 80 equals destination size with
+	   -Wstringop-truncation:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643
+	 */
+#if GCC_VERSION == 8001
+	DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION;
+#endif
 	strncpy (data + 48, va_arg (ap, const char *), 80);
+	DIAGNOSTIC_POP;
 	va_end (ap);
 	return elfcore_write_note (abfd, buf, bufsiz,
 				   "CORE", note_type, data, sizeof (data));
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 99ceb76d3d..ebda1dacdc 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -3951,7 +3951,16 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz,
 	va_end (ap);
 
 	strncpy (data + 28, fname, 16);
+	DIAGNOSTIC_PUSH;
+	/* GCC 8.1 warns about 80 equals destination size with
+	   -Wstringop-truncation:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643
+	 */
+#if GCC_VERSION == 8001
+	DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION;
+#endif
 	strncpy (data + 44, psargs, 80);
+	DIAGNOSTIC_POP;
 	return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
 				   &data, sizeof (data));
       }
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index f543cb0288..16199fbe3e 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -3041,7 +3041,16 @@ ppc64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_type,
 	va_start (ap, note_type);
 	memset (data, 0, sizeof (data));
 	strncpy (data + 40, va_arg (ap, const char *), 16);
+	DIAGNOSTIC_PUSH;
+	/* GCC 8.1 warns about 80 equals destination size with
+	   -Wstringop-truncation:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643
+	 */
+#if GCC_VERSION == 8001
+	DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION;
+#endif
 	strncpy (data + 56, va_arg (ap, const char *), 80);
+	DIAGNOSTIC_POP;
 	va_end (ap);
 	return elfcore_write_note (abfd, buf, bufsiz,
 				   "CORE", note_type, data, sizeof (data));
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 612557fa74..93a3c7c22a 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -3760,7 +3760,16 @@ elf_s390_write_core_note (bfd *abfd, char *buf, int *bufsiz,
 	va_end (ap);
 
 	strncpy (data + 40, fname, 16);
+	DIAGNOSTIC_PUSH;
+	/* GCC 8.1 warns about 80 equals destination size with
+	   -Wstringop-truncation:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643
+	 */
+#if GCC_VERSION == 8001
+	DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION;
+#endif
 	strncpy (data + 56, psargs, 80);
+	DIAGNOSTIC_POP;
 	return elfcore_write_note (abfd, buf, bufsiz, "CORE", note_type,
 				   &data, sizeof (data));
       }
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index af37f828d5..3ea8dadf6d 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -640,7 +640,16 @@ _bfd_aarch64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_ty
 	va_start (ap, note_type);
 	memset (data, 0, sizeof (data));
 	strncpy (data + 40, va_arg (ap, const char *), 16);
+	DIAGNOSTIC_PUSH;
+	/* GCC 8.1 warns about 80 equals destination size with
+	   -Wstringop-truncation:
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85643
+	 */
+#if GCC_VERSION == 8001
+	DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION;
+#endif
 	strncpy (data + 56, va_arg (ap, const char *), 80);
+	DIAGNOSTIC_POP;
 	va_end (ap);
 
 	return elfcore_write_note (abfd, buf, bufsiz, "CORE",
diff --git a/include/diagnostics.h b/include/diagnostics.h
index f7412d4a38..4a674106dc 100644
--- a/include/diagnostics.h
+++ b/include/diagnostics.h
@@ -48,10 +48,8 @@
 # define DIAGNOSTIC_IGNORE_UNUSED_FUNCTION \
   DIAGNOSTIC_IGNORE ("-Wunused-function")
 
-# if __GNUC__ == 8 && __GNUC_MINOR__ < 2
-#  define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
+# define DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION \
   DIAGNOSTIC_IGNORE ("-Wstringop-truncation")
-# endif
 #endif
 
 #ifndef DIAGNOSTIC_IGNORE_SELF_MOVE
-- 
2.17.1


  reply	other threads:[~2018-06-04 16:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21 12:16 [PATCH 1/3] Move gdb/common/diagnostics.h to include/diagnostics.h H.J. Lu
2018-05-21 13:10 ` [PATCH 2/3] Add DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION H.J. Lu
2018-06-01  7:57   ` Nick Clifton
     [not found]     ` <20180601101949.GA7660@bubble.grove.modra.org>
2018-06-01 16:51       ` H.J. Lu
2018-06-04 12:13         ` Nick Clifton
2018-06-04 12:19           ` Pedro Alves
2018-06-04 12:46             ` H.J. Lu
     [not found]               ` <CAMe9rOox6mZ6MX=GyC7-XJ2GuDzc5cjrLDyc3Hei5gBR4fWw7w@mail.gmail.com>
2018-06-04 13:40                 ` Pedro Alves
2018-06-04 14:04               ` Pedro Alves
2018-05-21 13:12 ` [PATCH 3/3] Use DIAGNOSTIC_IGNORE_STRINGOP_TRUNCATION to silence GCC 8 H.J. Lu
2018-06-01  7:59   ` Nick Clifton
2018-06-04 16:58     ` H.J. Lu [this message]
2018-06-04 17:06       ` Pedro Alves
2018-07-02 16:25       ` Tulio Magno Quites Machado Filho
2018-05-21 14:12 ` [PATCH 1/3] Move gdb/common/diagnostics.h to include/diagnostics.h Simon Marchi
2018-06-01  7:49 ` Nick Clifton
     [not found] ` <B781F464-751E-4D45-8881-36F6003759BE@glasgow.ac.uk>
2018-06-04 13:12   ` H.J. Lu
2018-06-04 13:24     ` John Marshall
2018-06-04 13:35     ` Pedro Alves
2018-06-04 13:37       ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMe9rOo24=MWapo0tU5cSJKRULnV_oLq1djxXEZ5chXe6DeZNQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    --cc=nickc@redhat.com \
    --cc=palves@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox