diff options
| author | mrg <mrg@NetBSD.org> | 2018-02-04 01:13:45 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2018-02-04 01:13:45 +0000 |
| commit | 8ca12eafd302fa1b84a7cb1791c4f721c48a71fd (patch) | |
| tree | 4b66ad42afa64b81fe9a71da7c5cc5397adfd3b3 /lib/libc/stdio | |
| parent | 60662d108045c74e964aa980e064cc09b426dc08 (diff) | |
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 (limited to 'lib/libc/stdio')
| -rw-r--r-- | lib/libc/stdio/fprintf.c | 5 | ||||
| -rw-r--r-- | lib/libc/stdio/fputc.c | 6 | ||||
| -rw-r--r-- | lib/libc/stdio/fputs.c | 11 | ||||
| -rw-r--r-- | lib/libc/stdio/fwrite.c | 6 | ||||
| -rw-r--r-- | lib/libc/stdio/putc.c | 8 | ||||
| -rw-r--r-- | lib/libc/stdio/puts.c | 10 | ||||
| -rw-r--r-- | lib/libc/stdio/scanf.c | 8 | ||||
| -rw-r--r-- | lib/libc/stdio/sscanf.c | 8 | ||||
| -rw-r--r-- | lib/libc/stdio/vprintf.c | 6 | ||||
| -rw-r--r-- | lib/libc/stdio/vscanf.c | 8 |
10 files changed, 26 insertions, 50 deletions
diff --git a/lib/libc/stdio/fprintf.c b/lib/libc/stdio/fprintf.c index 9b00d7d0d00..c7c054e5384 100644 --- a/lib/libc/stdio/fprintf.c +++ b/lib/libc/stdio/fprintf.c @@ -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 @@ fprintf(FILE *fp, const char *fmt, ...) va_list ap; _DIAGASSERT(fp != NULL); - _DIAGASSERT(fmt != NULL); va_start(ap, fmt); ret = vfprintf(fp, fmt, ap); diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c index e077a5ccd36..ec48a9c13df 100644 --- a/lib/libc/stdio/fputc.c +++ b/lib/libc/stdio/fputc.c @@ -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 @@ fputc(int c, FILE *fp) { int r; - _DIAGASSERT(fp != NULL); - FLOCKFILE(fp); r = __sputc(c, fp); FUNLOCKFILE(fp); diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c index d8852caf4be..7ad7f2f58d7 100644 --- a/lib/libc/stdio/fputs.c +++ b/lib/libc/stdio/fputs.c @@ -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 @@ fputs(const char *s, FILE *fp) { 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 --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c index 0004eb99098..b3ecc187cf2 100644 --- a/lib/libc/stdio/fwrite.c +++ b/lib/libc/stdio/fwrite.c @@ -1,4 +1,4 @@ -/* $NetBSD: fwrite.c,v 1.17 2012/03/15 18:22:30 christos Exp $ */ +/* $NetBSD: fwrite.c,v 1.18 2018/02/04 01:13:45 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)fwrite.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: fwrite.c,v 1.17 2012/03/15 18:22:30 christos Exp $"); +__RCSID("$NetBSD: fwrite.c,v 1.18 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -59,13 +59,11 @@ fwrite(const void *buf, size_t size, size_t count, FILE *fp) struct __suio uio; struct __siov iov; - _DIAGASSERT(fp != NULL); /* * SUSv2 requires a return value of 0 for a count or a size of 0. */ if ((n = count * size) == 0) return 0; - _DIAGASSERT(buf != NULL); iov.iov_base = __UNCONST(buf); uio.uio_resid = iov.iov_len = n; diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c index 858c76ce299..ad57090e2fd 100644 --- a/lib/libc/stdio/putc.c +++ b/lib/libc/stdio/putc.c @@ -1,4 +1,4 @@ -/* $NetBSD: putc.c,v 1.12 2012/03/15 18:22:30 christos Exp $ */ +/* $NetBSD: putc.c,v 1.13 2018/02/04 01:13:45 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)putc.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: putc.c,v 1.12 2012/03/15 18:22:30 christos Exp $"); +__RCSID("$NetBSD: putc.c,v 1.13 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -58,8 +58,6 @@ putc(int c, FILE *fp) { int r; - _DIAGASSERT(fp != NULL); - FLOCKFILE(fp); r = __sputc(c, fp); FUNLOCKFILE(fp); @@ -70,7 +68,5 @@ int putc_unlocked(int c, FILE *fp) { - _DIAGASSERT(fp != NULL); - return __sputc(c, fp); } diff --git a/lib/libc/stdio/puts.c b/lib/libc/stdio/puts.c index 0ffa7d1cd2a..25bef405823 100644 --- a/lib/libc/stdio/puts.c +++ b/lib/libc/stdio/puts.c @@ -1,4 +1,4 @@ -/* $NetBSD: puts.c,v 1.16 2012/03/15 18:22:30 christos Exp $ */ +/* $NetBSD: puts.c,v 1.17 2018/02/04 01:13:45 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)puts.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: puts.c,v 1.16 2012/03/15 18:22:30 christos Exp $"); +__RCSID("$NetBSD: puts.c,v 1.17 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -58,11 +58,11 @@ puts(char const *s) size_t c; struct __suio uio; struct __siov iov[2]; + const void *vs = s; int r; - _DIAGASSERT(s != NULL); - - if (s == NULL) + /* This avoids -Werror=nonnull-compare. */ + if (vs == NULL) s = "(null)"; c = strlen(s); diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c index b2f7d9a53fc..bc71a6758b1 100644 --- a/lib/libc/stdio/scanf.c +++ b/lib/libc/stdio/scanf.c @@ -1,4 +1,4 @@ -/* $NetBSD: scanf.c,v 1.14 2013/04/19 23:32:17 joerg Exp $ */ +/* $NetBSD: scanf.c,v 1.15 2018/02/04 01:13:45 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)scanf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: scanf.c,v 1.14 2013/04/19 23:32:17 joerg Exp $"); +__RCSID("$NetBSD: scanf.c,v 1.15 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -59,8 +59,6 @@ scanf(char const *fmt, ...) int ret; va_list ap; - _DIAGASSERT(fmt != NULL); - va_start(ap, fmt); ret = __svfscanf(stdin, fmt, ap); va_end(ap); @@ -73,8 +71,6 @@ scanf_l(locale_t loc, char const *fmt, ...) int ret; va_list ap; - _DIAGASSERT(fmt != NULL); - va_start(ap, fmt); ret = __svfscanf_l(stdin, loc, fmt, ap); va_end(ap); diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c index 6a995c34230..56f6c4961fb 100644 --- a/lib/libc/stdio/sscanf.c +++ b/lib/libc/stdio/sscanf.c @@ -1,4 +1,4 @@ -/* $NetBSD: sscanf.c,v 1.21 2013/04/19 23:32:17 joerg Exp $ */ +/* $NetBSD: sscanf.c,v 1.22 2018/02/04 01:13:45 mrg Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)sscanf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: sscanf.c,v 1.21 2013/04/19 23:32:17 joerg Exp $"); +__RCSID("$NetBSD: sscanf.c,v 1.22 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -60,8 +60,6 @@ sscanf(const char *str, char const *fmt, ...) int ret; va_list ap; - _DIAGASSERT(fmt != NULL); - va_start(ap, fmt); ret = vsscanf(str, fmt, ap); va_end(ap); @@ -74,8 +72,6 @@ sscanf_l(const char *str, locale_t loc, char const *fmt, ...) int ret; va_list ap; - _DIAGASSERT(fmt != NULL); - va_start(ap, fmt); ret = vsscanf_l(str, loc, fmt, ap); va_end(ap); diff --git a/lib/libc/stdio/vprintf.c b/lib/libc/stdio/vprintf.c index ccc789b429d..d5b4e3d6196 100644 --- a/lib/libc/stdio/vprintf.c +++ b/lib/libc/stdio/vprintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: vprintf.c,v 1.13 2013/04/19 15:22:25 joerg Exp $ */ +/* $NetBSD: vprintf.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[] = "@(#)vprintf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: vprintf.c,v 1.13 2013/04/19 15:22:25 joerg Exp $"); +__RCSID("$NetBSD: vprintf.c,v 1.14 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -53,8 +53,6 @@ int vprintf(const char *fmt, va_list ap) { - _DIAGASSERT(fmt != NULL); - return vfprintf(stdout, fmt, ap); } diff --git a/lib/libc/stdio/vscanf.c b/lib/libc/stdio/vscanf.c index ac293fabb52..26a9b1b5c44 100644 --- a/lib/libc/stdio/vscanf.c +++ b/lib/libc/stdio/vscanf.c @@ -1,4 +1,4 @@ -/* $NetBSD: vscanf.c,v 1.15 2013/04/19 23:32:17 joerg Exp $ */ +/* $NetBSD: vscanf.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[] = "@(#)vscanf.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: vscanf.c,v 1.15 2013/04/19 23:32:17 joerg Exp $"); +__RCSID("$NetBSD: vscanf.c,v 1.16 2018/02/04 01:13:45 mrg Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -56,8 +56,6 @@ int vscanf(const char *fmt, va_list ap) { - _DIAGASSERT(fmt != NULL); - return __svfscanf(stdin, fmt, ap); } @@ -65,7 +63,5 @@ int vscanf_l(locale_t loc, const char *fmt, va_list ap) { - _DIAGASSERT(fmt != NULL); - return __svfscanf_l(stdin, loc, fmt, ap); } |
