Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src fixes for GCC 6:



details:   https://anonhg.NetBSD.org/src/rev/8101dc773f72
branches:  trunk
changeset: 829485:8101dc773f72
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Feb 04 01:13:45 2018 +0000

description:
fixes for GCC 6:

- -Wstrict-prototypes is not available for C++, so don't try to
  ignore it for C++.
- remove many _DIAGASSERT() checks against not NULL for functions
  with arguments with nonnull attributes.  in two cases, leave
  code behind that should set defaults to "(null)".
- use -Wno-error=frame-address for i386 mcount, as it seems valid
  to assume the caller will have a frame.fair

diffstat:

 common/lib/libc/string/strcspn.c |   7 ++-----
 common/lib/libc/string/strncat.c |   7 ++-----
 common/lib/libc/string/strncpy.c |   7 ++-----
 common/lib/libc/string/strpbrk.c |   7 ++-----
 common/lib/libc/string/strspn.c  |   7 ++-----
 common/lib/libc/string/strstr.c  |   7 ++-----
 include/ucontext.h               |   4 +++-
 lib/libc/gmon/Makefile.inc       |   7 ++++++-
 lib/libc/stdio/fprintf.c         |   5 ++---
 lib/libc/stdio/fputc.c           |   6 ++----
 lib/libc/stdio/fputs.c           |  11 +++++------
 lib/libc/stdio/fwrite.c          |   6 ++----
 lib/libc/stdio/putc.c            |   8 ++------
 lib/libc/stdio/puts.c            |  10 +++++-----
 lib/libc/stdio/scanf.c           |   8 ++------
 lib/libc/stdio/sscanf.c          |   8 ++------
 lib/libc/stdio/vprintf.c         |   6 ++----
 lib/libc/stdio/vscanf.c          |   8 ++------
 18 files changed, 47 insertions(+), 82 deletions(-)

diffs (truncated from 529 to 300 lines):

diff -r 50e66c3027e7 -r 8101dc773f72 common/lib/libc/string/strcspn.c
--- a/common/lib/libc/string/strcspn.c  Sat Feb 03 22:43:37 2018 +0000
+++ b/common/lib/libc/string/strcspn.c  Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strcspn.c,v 1.1 2014/07/19 18:38:33 lneto Exp $        */
+/*     $NetBSD: strcspn.c,v 1.2 2018/02/04 01:13:45 mrg Exp $  */
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: strcspn.c,v 1.1 2014/07/19 18:38:33 lneto Exp $");
+__RCSID("$NetBSD: strcspn.c,v 1.2 2018/02/04 01:13:45 mrg Exp $");
 
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 #include <assert.h>
@@ -48,9 +48,6 @@
        uint8_t set[32];
 #define UC(a) ((unsigned int)(unsigned char)(a))
 
-       _DIAGASSERT(s != NULL);
-       _DIAGASSERT(charset != NULL);
-
        if (charset[0] == '\0')
                return strlen(s);
        if (charset[1] == '\0') {
diff -r 50e66c3027e7 -r 8101dc773f72 common/lib/libc/string/strncat.c
--- a/common/lib/libc/string/strncat.c  Sat Feb 03 22:43:37 2018 +0000
+++ b/common/lib/libc/string/strncat.c  Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strncat.c,v 1.2 2013/12/27 20:26:53 christos Exp $     */
+/*     $NetBSD: strncat.c,v 1.3 2018/02/04 01:13:45 mrg Exp $  */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)strncat.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: strncat.c,v 1.2 2013/12/27 20:26:53 christos Exp $");
+__RCSID("$NetBSD: strncat.c,v 1.3 2018/02/04 01:13:45 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -60,9 +60,6 @@
 strncat(char *dst, const char *src, size_t n)
 {
 
-       _DIAGASSERT(dst != NULL);
-       _DIAGASSERT(src != NULL);
-
        if (n != 0) {
                char *d = dst;
                const char *s = src;
diff -r 50e66c3027e7 -r 8101dc773f72 common/lib/libc/string/strncpy.c
--- a/common/lib/libc/string/strncpy.c  Sat Feb 03 22:43:37 2018 +0000
+++ b/common/lib/libc/string/strncpy.c  Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strncpy.c,v 1.3 2007/06/04 18:19:28 christos Exp $     */
+/*     $NetBSD: strncpy.c,v 1.4 2018/02/04 01:13:45 mrg Exp $  */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)strncpy.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: strncpy.c,v 1.3 2007/06/04 18:19:28 christos Exp $");
+__RCSID("$NetBSD: strncpy.c,v 1.4 2018/02/04 01:13:45 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -60,9 +60,6 @@
 strncpy(char *dst, const char *src, size_t n)
 {
 
-       _DIAGASSERT(dst != NULL);
-       _DIAGASSERT(src != NULL);
-
        if (n != 0) {
                char *d = dst;
                const char *s = src;
diff -r 50e66c3027e7 -r 8101dc773f72 common/lib/libc/string/strpbrk.c
--- a/common/lib/libc/string/strpbrk.c  Sat Feb 03 22:43:37 2018 +0000
+++ b/common/lib/libc/string/strpbrk.c  Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strpbrk.c,v 1.1 2014/07/19 18:38:33 lneto Exp $        */
+/*     $NetBSD: strpbrk.c,v 1.2 2018/02/04 01:13:45 mrg Exp $  */
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: strpbrk.c,v 1.1 2014/07/19 18:38:33 lneto Exp $");
+__RCSID("$NetBSD: strpbrk.c,v 1.2 2018/02/04 01:13:45 mrg Exp $");
 
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 #include <assert.h>
@@ -61,9 +61,6 @@
        (void)memset(set, 0, sizeof(set));
 #endif
 
-       _DIAGASSERT(s != NULL);
-       _DIAGASSERT(charset != NULL);
-
        if (charset[0] == '\0')
                return NULL;
        if (charset[1] == '\0')
diff -r 50e66c3027e7 -r 8101dc773f72 common/lib/libc/string/strspn.c
--- a/common/lib/libc/string/strspn.c   Sat Feb 03 22:43:37 2018 +0000
+++ b/common/lib/libc/string/strspn.c   Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strspn.c,v 1.1 2014/07/19 18:38:33 lneto Exp $ */
+/*     $NetBSD: strspn.c,v 1.2 2018/02/04 01:13:45 mrg Exp $   */
 
 /*-
  * Copyright (c) 2008 Joerg Sonnenberger
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: strspn.c,v 1.1 2014/07/19 18:38:33 lneto Exp $");
+__RCSID("$NetBSD: strspn.c,v 1.2 2018/02/04 01:13:45 mrg Exp $");
 
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 #include <assert.h>
@@ -47,9 +47,6 @@
        const char *t;
 #define UC(a) ((unsigned int)(unsigned char)(a))
 
-       _DIAGASSERT(s != NULL);
-       _DIAGASSERT(charset != NULL);
-
        if (charset[0] == '\0')
                return 0;
        if (charset[1] == '\0') {
diff -r 50e66c3027e7 -r 8101dc773f72 common/lib/libc/string/strstr.c
--- a/common/lib/libc/string/strstr.c   Sat Feb 03 22:43:37 2018 +0000
+++ b/common/lib/libc/string/strstr.c   Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: strstr.c,v 1.2 2007/06/04 18:19:28 christos Exp $      */
+/*     $NetBSD: strstr.c,v 1.3 2018/02/04 01:13:45 mrg Exp $   */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)strstr.c   8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: strstr.c,v 1.2 2007/06/04 18:19:28 christos Exp $");
+__RCSID("$NetBSD: strstr.c,v 1.3 2018/02/04 01:13:45 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -58,9 +58,6 @@
        char c, sc;
        size_t len;
 
-       _DIAGASSERT(s != NULL);
-       _DIAGASSERT(find != NULL);
-
        if ((c = *find++) != 0) {
                len = strlen(find);
                do {
diff -r 50e66c3027e7 -r 8101dc773f72 include/ucontext.h
--- a/include/ucontext.h        Sat Feb 03 22:43:37 2018 +0000
+++ b/include/ucontext.h        Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucontext.h,v 1.10 2017/01/15 20:10:25 christos Exp $   */
+/*     $NetBSD: ucontext.h,v 1.11 2018/02/04 01:13:45 mrg Exp $        */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -40,7 +40,9 @@
 int    setcontext(const ucontext_t *);
 
 #pragma GCC diagnostic push
+#ifndef  __cplusplus
 #pragma GCC diagnostic ignored "-Wstrict-prototypes"
+#endif
 void   makecontext(ucontext_t *, void (*)(), int, ...);
 #pragma GCC diagnostic pop
 
diff -r 50e66c3027e7 -r 8101dc773f72 lib/libc/gmon/Makefile.inc
--- a/lib/libc/gmon/Makefile.inc        Sat Feb 03 22:43:37 2018 +0000
+++ b/lib/libc/gmon/Makefile.inc        Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.11 2014/09/17 11:37:28 joerg Exp $
+#      $NetBSD: Makefile.inc,v 1.12 2018/02/04 01:13:45 mrg Exp $
 #      @(#)Makefile.inc        8.1 (Berkeley) 6/4/93
 
 # gmon sources
@@ -18,6 +18,11 @@
 COPTS.mcount.c+=${${ACTIVE_CXX} == "gcc":? -Wa,--no-warn :}
 .endif
 
+.if (${MACHINE_CPU} == "i386") && ${HAVE_GCC:U0} >= 6
+# The usage of __builtin_frame_address(1) should be OK.
+COPTS.mcount.c+=${${ACTIVE_CXX} == "gcc":? -Wno-error=frame-address :}
+.endif
+
 
 # mcount and gmon cannot be compiled with profiling
 mcount.po: mcount.o
diff -r 50e66c3027e7 -r 8101dc773f72 lib/libc/stdio/fprintf.c
--- a/lib/libc/stdio/fprintf.c  Sat Feb 03 22:43:37 2018 +0000
+++ b/lib/libc/stdio/fprintf.c  Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fprintf.c,v 1.13 2013/04/19 15:22:25 joerg Exp $       */
+/*     $NetBSD: fprintf.c,v 1.14 2018/02/04 01:13:45 mrg Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fprintf.c  8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fprintf.c,v 1.13 2013/04/19 15:22:25 joerg Exp $");
+__RCSID("$NetBSD: fprintf.c,v 1.14 2018/02/04 01:13:45 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -54,7 +54,6 @@
        va_list ap;
 
        _DIAGASSERT(fp != NULL);
-       _DIAGASSERT(fmt != NULL);
 
        va_start(ap, fmt);
        ret = vfprintf(fp, fmt, ap);
diff -r 50e66c3027e7 -r 8101dc773f72 lib/libc/stdio/fputc.c
--- a/lib/libc/stdio/fputc.c    Sat Feb 03 22:43:37 2018 +0000
+++ b/lib/libc/stdio/fputc.c    Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fputc.c,v 1.13 2012/03/15 18:22:30 christos Exp $      */
+/*     $NetBSD: fputc.c,v 1.14 2018/02/04 01:13:45 mrg Exp $   */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fputc.c    8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fputc.c,v 1.13 2012/03/15 18:22:30 christos Exp $");
+__RCSID("$NetBSD: fputc.c,v 1.14 2018/02/04 01:13:45 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -52,8 +52,6 @@
 {
        int r;
 
-       _DIAGASSERT(fp != NULL);
-
        FLOCKFILE(fp); 
        r = __sputc(c, fp);
        FUNLOCKFILE(fp);
diff -r 50e66c3027e7 -r 8101dc773f72 lib/libc/stdio/fputs.c
--- a/lib/libc/stdio/fputs.c    Sat Feb 03 22:43:37 2018 +0000
+++ b/lib/libc/stdio/fputs.c    Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fputs.c,v 1.15 2012/03/13 21:13:46 christos Exp $      */
+/*     $NetBSD: fputs.c,v 1.16 2018/02/04 01:13:45 mrg Exp $   */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)fputs.c    8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: fputs.c,v 1.15 2012/03/13 21:13:46 christos Exp $");
+__RCSID("$NetBSD: fputs.c,v 1.16 2018/02/04 01:13:45 mrg Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -57,12 +57,11 @@
 {
        struct __suio uio;
        struct __siov iov;
+       const void *vs = s;
        int r;
 
-       _DIAGASSERT(s != NULL);
-       _DIAGASSERT(fp != NULL);
-
-       if (s == NULL)
+       /* This avoids -Werror=nonnull-compare. */
+       if (vs == NULL)
                s = "(null)";
 
        iov.iov_base = __UNCONST(s);
diff -r 50e66c3027e7 -r 8101dc773f72 lib/libc/stdio/fwrite.c
--- a/lib/libc/stdio/fwrite.c   Sat Feb 03 22:43:37 2018 +0000
+++ b/lib/libc/stdio/fwrite.c   Sun Feb 04 01:13:45 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fwrite.c,v 1.17 2012/03/15 18:22:30 christos Exp $     */



Home | Main Index | Thread Index | Old Index