Discussion:
[newlib-cygwin] Cygwin: fix bumptious GCC 7 warnings
Corinna Vinschen
2018-06-26 15:21:10 UTC
Permalink
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6497fdfaf41d47e835fdefc78ecb0a934875d7cf

commit 6497fdfaf41d47e835fdefc78ecb0a934875d7cf
Author: Corinna Vinschen <***@vinschen.de>
Date: Tue Jun 26 17:20:48 2018 +0200

Cygwin: fix bumptious GCC 7 warnings

Signed-off-by: Corinna Vinschen <***@vinschen.de>

Diff:
---
winsup/cygserver/sysv_sem.cc | 2 +-
winsup/utils/dumper.cc | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/winsup/cygserver/sysv_sem.cc b/winsup/cygserver/sysv_sem.cc
index 349322c..76efab4 100644
--- a/winsup/cygserver/sysv_sem.cc
+++ b/winsup/cygserver/sysv_sem.cc
@@ -249,7 +249,7 @@ seminit(void)
for (i = 0; i < seminfo.semmni; i++)
{
char *buf = (char *) sys_malloc(16, M_SEM, M_WAITOK);
- snprintf(buf, 16, "semid[%d]", i);
+ snprintf(buf, 16, "semid[%d]", (short) i);
mtx_init(&sema_mtx[i], buf, NULL, MTX_DEF);
}
for (i = 0; i < seminfo.semmnu; i++) {
diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc
index b2e03e8..14b9933 100644
--- a/winsup/utils/dumper.cc
+++ b/winsup/utils/dumper.cc
@@ -415,7 +415,10 @@ dumper::dump_thread (asection * to, process_thread * thread)
bfd_putl32 (NOTE_NAME_SIZE, header.elf_note_header.namesz);
bfd_putl32 (sizeof (thread_pstatus), header.elf_note_header.descsz);
bfd_putl32 (NT_WIN32PSTATUS, header.elf_note_header.type);
- strncpy ((char *) &header.elf_note_header.name, "win32thread", NOTE_NAME_SIZE);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ strncpy (header.elf_note_header.name, "win32thread", NOTE_NAME_SIZE);
+#pragma GCC diagnostic pop

thread_pstatus.data_type = NOTE_INFO_THREAD;
thread_pstatus.data.thread_info.tid = thread->tid;
@@ -478,7 +481,10 @@ dumper::dump_module (asection * to, process_module * module)
bfd_putl32 (NOTE_NAME_SIZE, header.elf_note_header.namesz);
bfd_putl32 (note_length, header.elf_note_header.descsz);
bfd_putl32 (NT_WIN32PSTATUS, header.elf_note_header.type);
- strncpy ((char *) &header.elf_note_header.name, "win32module", NOTE_NAME_SIZE);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+ strncpy (header.elf_note_header.name, "win32module", NOTE_NAME_SIZE);
+#pragma GCC diagnostic pop

module_pstatus_ptr->data_type = NOTE_INFO_MODULE;
module_pstatus_ptr->data.module_info.base_address = module->base_address;
Loading...