Module Name:    src
Committed By:   mrg
Date:           Sun Feb  4 01:13:45 UTC 2018

Modified Files:
        src/common/lib/libc/string: strcspn.c strncat.c strncpy.c strpbrk.c
            strspn.c strstr.c
        src/include: ucontext.h
        src/lib/libc/gmon: Makefile.inc
        src/lib/libc/stdio: fprintf.c fputc.c fputs.c fwrite.c putc.c puts.c
            scanf.c sscanf.c vprintf.c vscanf.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/string/strcspn.c \
    src/common/lib/libc/string/strpbrk.c src/common/lib/libc/string/strspn.c
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/string/strncat.c \
    src/common/lib/libc/string/strstr.c
cvs rdiff -u -r1.3 -r1.4 src/common/lib/libc/string/strncpy.c
cvs rdiff -u -r1.10 -r1.11 src/include/ucontext.h
cvs rdiff -u -r1.11 -r1.12 src/lib/libc/gmon/Makefile.inc
cvs rdiff -u -r1.13 -r1.14 src/lib/libc/stdio/fprintf.c \
    src/lib/libc/stdio/fputc.c src/lib/libc/stdio/vprintf.c
cvs rdiff -u -r1.15 -r1.16 src/lib/libc/stdio/fputs.c \
    src/lib/libc/stdio/vscanf.c
cvs rdiff -u -r1.17 -r1.18 src/lib/libc/stdio/fwrite.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libc/stdio/putc.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libc/stdio/puts.c
cvs rdiff -u -r1.14 -r1.15 src/lib/libc/stdio/scanf.c
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/stdio/sscanf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/string/strcspn.c
diff -u src/common/lib/libc/string/strcspn.c:1.1 src/common/lib/libc/string/strcspn.c:1.2
--- src/common/lib/libc/string/strcspn.c:1.1	Sat Jul 19 18:38:33 2014
+++ src/common/lib/libc/string/strcspn.c	Sun Feb  4 01:13:45 2018
@@ -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 @@ strcspn(const char *s, const char *chars
 	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') {
Index: src/common/lib/libc/string/strpbrk.c
diff -u src/common/lib/libc/string/strpbrk.c:1.1 src/common/lib/libc/string/strpbrk.c:1.2
--- src/common/lib/libc/string/strpbrk.c:1.1	Sat Jul 19 18:38:33 2014
+++ src/common/lib/libc/string/strpbrk.c	Sun Feb  4 01:13:45 2018
@@ -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 @@ strpbrk(const char *s, const char *chars
 	(void)memset(set, 0, sizeof(set));
 #endif
 
-	_DIAGASSERT(s != NULL);
-	_DIAGASSERT(charset != NULL);
-
 	if (charset[0] == '\0')
 		return NULL;
 	if (charset[1] == '\0')
Index: src/common/lib/libc/string/strspn.c
diff -u src/common/lib/libc/string/strspn.c:1.1 src/common/lib/libc/string/strspn.c:1.2
--- src/common/lib/libc/string/strspn.c:1.1	Sat Jul 19 18:38:33 2014
+++ src/common/lib/libc/string/strspn.c	Sun Feb  4 01:13:45 2018
@@ -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 @@ strspn(const char *s, const char *charse
 	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') {

Index: src/common/lib/libc/string/strncat.c
diff -u src/common/lib/libc/string/strncat.c:1.2 src/common/lib/libc/string/strncat.c:1.3
--- src/common/lib/libc/string/strncat.c:1.2	Fri Dec 27 20:26:53 2013
+++ src/common/lib/libc/string/strncat.c	Sun Feb  4 01:13:45 2018
@@ -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 @@ char *
 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;
Index: src/common/lib/libc/string/strstr.c
diff -u src/common/lib/libc/string/strstr.c:1.2 src/common/lib/libc/string/strstr.c:1.3
--- src/common/lib/libc/string/strstr.c:1.2	Mon Jun  4 18:19:28 2007
+++ src/common/lib/libc/string/strstr.c	Sun Feb  4 01:13:45 2018
@@ -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 @@ strstr(const char *s, const char *find)
 	char c, sc;
 	size_t len;
 
-	_DIAGASSERT(s != NULL);
-	_DIAGASSERT(find != NULL);
-
 	if ((c = *find++) != 0) {
 		len = strlen(find);
 		do {

Index: src/common/lib/libc/string/strncpy.c
diff -u src/common/lib/libc/string/strncpy.c:1.3 src/common/lib/libc/string/strncpy.c:1.4
--- src/common/lib/libc/string/strncpy.c:1.3	Mon Jun  4 18:19:28 2007
+++ src/common/lib/libc/string/strncpy.c	Sun Feb  4 01:13:45 2018
@@ -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 @@ char *
 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;

Index: src/include/ucontext.h
diff -u src/include/ucontext.h:1.10 src/include/ucontext.h:1.11
--- src/include/ucontext.h:1.10	Sun Jan 15 20:10:25 2017
+++ src/include/ucontext.h	Sun Feb  4 01:13:45 2018
@@ -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	getcontext(ucontext_t *) __returns_t
 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
 

Index: src/lib/libc/gmon/Makefile.inc
diff -u src/lib/libc/gmon/Makefile.inc:1.11 src/lib/libc/gmon/Makefile.inc:1.12
--- src/lib/libc/gmon/Makefile.inc:1.11	Wed Sep 17 11:37:28 2014
+++ src/lib/libc/gmon/Makefile.inc	Sun Feb  4 01:13:45 2018
@@ -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 @@ MLINKS+=moncontrol.3 monstartup.3
 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

Index: src/lib/libc/stdio/fprintf.c
diff -u src/lib/libc/stdio/fprintf.c:1.13 src/lib/libc/stdio/fprintf.c:1.14
--- src/lib/libc/stdio/fprintf.c:1.13	Fri Apr 19 15:22:25 2013
+++ src/lib/libc/stdio/fprintf.c	Sun Feb  4 01:13:45 2018
@@ -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);
Index: src/lib/libc/stdio/fputc.c
diff -u src/lib/libc/stdio/fputc.c:1.13 src/lib/libc/stdio/fputc.c:1.14
--- src/lib/libc/stdio/fputc.c:1.13	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/fputc.c	Sun Feb  4 01:13:45 2018
@@ -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);
Index: src/lib/libc/stdio/vprintf.c
diff -u src/lib/libc/stdio/vprintf.c:1.13 src/lib/libc/stdio/vprintf.c:1.14
--- src/lib/libc/stdio/vprintf.c:1.13	Fri Apr 19 15:22:25 2013
+++ src/lib/libc/stdio/vprintf.c	Sun Feb  4 01:13:45 2018
@@ -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);
 }
 

Index: src/lib/libc/stdio/fputs.c
diff -u src/lib/libc/stdio/fputs.c:1.15 src/lib/libc/stdio/fputs.c:1.16
--- src/lib/libc/stdio/fputs.c:1.15	Tue Mar 13 21:13:46 2012
+++ src/lib/libc/stdio/fputs.c	Sun Feb  4 01:13:45 2018
@@ -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);
Index: src/lib/libc/stdio/vscanf.c
diff -u src/lib/libc/stdio/vscanf.c:1.15 src/lib/libc/stdio/vscanf.c:1.16
--- src/lib/libc/stdio/vscanf.c:1.15	Fri Apr 19 23:32:17 2013
+++ src/lib/libc/stdio/vscanf.c	Sun Feb  4 01:13:45 2018
@@ -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);
 }

Index: src/lib/libc/stdio/fwrite.c
diff -u src/lib/libc/stdio/fwrite.c:1.17 src/lib/libc/stdio/fwrite.c:1.18
--- src/lib/libc/stdio/fwrite.c:1.17	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/fwrite.c	Sun Feb  4 01:13:45 2018
@@ -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, siz
 	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;

Index: src/lib/libc/stdio/putc.c
diff -u src/lib/libc/stdio/putc.c:1.12 src/lib/libc/stdio/putc.c:1.13
--- src/lib/libc/stdio/putc.c:1.12	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/putc.c	Sun Feb  4 01:13:45 2018
@@ -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);
 }

Index: src/lib/libc/stdio/puts.c
diff -u src/lib/libc/stdio/puts.c:1.16 src/lib/libc/stdio/puts.c:1.17
--- src/lib/libc/stdio/puts.c:1.16	Thu Mar 15 18:22:30 2012
+++ src/lib/libc/stdio/puts.c	Sun Feb  4 01:13:45 2018
@@ -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);

Index: src/lib/libc/stdio/scanf.c
diff -u src/lib/libc/stdio/scanf.c:1.14 src/lib/libc/stdio/scanf.c:1.15
--- src/lib/libc/stdio/scanf.c:1.14	Fri Apr 19 23:32:17 2013
+++ src/lib/libc/stdio/scanf.c	Sun Feb  4 01:13:45 2018
@@ -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);

Index: src/lib/libc/stdio/sscanf.c
diff -u src/lib/libc/stdio/sscanf.c:1.21 src/lib/libc/stdio/sscanf.c:1.22
--- src/lib/libc/stdio/sscanf.c:1.21	Fri Apr 19 23:32:17 2013
+++ src/lib/libc/stdio/sscanf.c	Sun Feb  4 01:13:45 2018
@@ -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, 
 	int ret;
 	va_list ap;
 
-	_DIAGASSERT(fmt != NULL);
-
 	va_start(ap, fmt);
 	ret = vsscanf_l(str, loc, fmt, ap);
 	va_end(ap);

Reply via email to