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
This commit is contained in:
mrg 2018-02-04 01:13:45 +00:00
parent c9496f6b60
commit 8fdd01b3ee
18 changed files with 47 additions and 82 deletions

View File

@ -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 *charset)
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') {

View File

@ -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;

View File

@ -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;

View File

@ -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 *charset)
(void)memset(set, 0, sizeof(set));
#endif
_DIAGASSERT(s != NULL);
_DIAGASSERT(charset != NULL);
if (charset[0] == '\0')
return NULL;
if (charset[1] == '\0')

View File

@ -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 *charset)
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') {

View File

@ -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 {

View File

@ -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_twice;
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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}