Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc PR/45989: Martin Husemann: lint invocation does inc...
details: https://anonhg.NetBSD.org/src/rev/8d167eea3cbe
branches: trunk
changeset: 778038:8d167eea3cbe
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 13 21:13:30 2012 +0000
description:
PR/45989: Martin Husemann: lint invocation does include -w only on i386
- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)
approved by core@
diffstat:
lib/libc/Makefile.inc | 6 +-
lib/libc/cdb/cdbw.c | 34 ++++--
lib/libc/citrus/citrus_memstream.c | 6 +-
lib/libc/compat/db/hash/compat_ndbmdatum.c | 4 +-
lib/libc/compat/gen/compat___fts13.c | 7 +-
lib/libc/compat/gen/compat___fts30.c | 7 +-
lib/libc/compat/gen/compat___fts31.c | 7 +-
lib/libc/compat/sys/compat_getdents.c | 13 ++-
lib/libc/compat/sys/compat_sigaltstack.c | 6 +-
lib/libc/db/btree/bt_open.c | 12 +-
lib/libc/db/btree/bt_overflow.c | 6 +-
lib/libc/db/hash/hash.c | 10 +-
lib/libc/db/hash/hash_bigkey.c | 16 ++-
lib/libc/db/hash/hash_page.c | 6 +-
lib/libc/db/hash/ndbmdatum.c | 13 +-
lib/libc/dlfcn/dlfcn_elf.c | 8 +-
lib/libc/gdtoa/gdtoa.c | 6 +-
lib/libc/gdtoa/gdtoaimp.h | 5 +-
lib/libc/gdtoa/gmisc.c | 7 +-
lib/libc/gdtoa/smisc.c | 4 +-
lib/libc/gdtoa/strtod.c | 4 +-
lib/libc/gdtoa/strtodg.c | 4 +-
lib/libc/gen/dehumanize_number.c | 9 +-
lib/libc/gen/disklabel.c | 6 +-
lib/libc/gen/extattr.c | 16 +-
lib/libc/gen/fstab.c | 6 +-
lib/libc/gen/fts.c | 31 +++++-
lib/libc/gen/getcap.c | 24 +++--
lib/libc/gen/getcwd.c | 7 +-
lib/libc/gen/getdevmajor.c | 14 +-
lib/libc/gen/getgrent.c | 8 +-
lib/libc/gen/getloadavg.c | 25 ++---
lib/libc/gen/getusershell.c | 7 +-
lib/libc/gen/humanize_number.c | 18 ++-
lib/libc/gen/initdir.c | 7 +-
lib/libc/gen/psignal.c | 6 +-
lib/libc/gen/pw_scan.c | 12 +-
lib/libc/gen/scandir.c | 7 +-
lib/libc/gen/sysctl.c | 10 +-
lib/libc/gen/sysctlgetmibinfo.c | 21 ++--
lib/libc/gen/sysctlnametomib.c | 8 +-
lib/libc/gen/syslog.c | 6 +-
lib/libc/gen/time.c | 8 +-
lib/libc/gen/unvis.c | 6 +-
lib/libc/gen/utmpx.c | 6 +-
lib/libc/gmon/gmon.c | 6 +-
lib/libc/inet/inet_cidr_ntop.c | 8 +-
lib/libc/inet/inet_cidr_pton.c | 14 +-
lib/libc/inet/inet_net_pton.c | 19 ++-
lib/libc/inet/inet_neta.c | 8 +-
lib/libc/inet/inet_ntoa.c | 8 +-
lib/libc/inet/inet_pton.c | 13 +-
lib/libc/isc/ev_timers.c | 6 +-
lib/libc/md/mdXhl.c | 5 +-
lib/libc/misc/stack_protector.c | 8 +-
lib/libc/nameser/ns_name.c | 57 +++++++----
lib/libc/nameser/ns_netint.c | 20 ++--
lib/libc/nameser/ns_parse.c | 8 +-
lib/libc/nameser/ns_print.c | 50 ++++++----
lib/libc/nameser/ns_ttl.c | 18 ++-
lib/libc/net/base64.c | 26 +++--
lib/libc/net/ethers.c | 6 +-
lib/libc/net/getaddrinfo.c | 26 ++--
lib/libc/net/gethnamaddr.c | 39 ++++----
lib/libc/net/getifaddrs.c | 29 +++---
lib/libc/net/getnameinfo.c | 13 +-
lib/libc/net/getnetent.c | 6 +-
lib/libc/net/getnetnamadr.c | 15 +-
lib/libc/net/getservbyname_r.c | 8 +-
lib/libc/net/getservbyport_r.c | 6 +-
lib/libc/net/if_nameindex.c | 7 +-
lib/libc/net/ip6opt.c | 53 ++++++++---
lib/libc/net/iso_addr.c | 7 +-
lib/libc/net/linkaddr.c | 29 +++--
lib/libc/net/nsdispatch.c | 7 +-
lib/libc/net/rcmd.c | 36 ++++---
lib/libc/net/rthdr.c | 55 +++++------
lib/libc/quad/fixunsdfdi.c | 6 +-
lib/libc/quad/fixunssfdi.c | 6 +-
lib/libc/quad/floatdidf.c | 6 +-
lib/libc/quad/floatdisf.c | 6 +-
lib/libc/quad/floatundidf.c | 6 +-
lib/libc/quad/floatundisf.c | 6 +-
lib/libc/regex/engine.c | 6 +-
lib/libc/regex/regcomp.c | 46 +++++----
lib/libc/regex/regexec.c | 6 +-
lib/libc/resolv/herror.c | 6 +-
lib/libc/resolv/res_comp.c | 8 +-
lib/libc/resolv/res_debug.c | 32 ++++--
lib/libc/resolv/res_debug.h | 4 +-
lib/libc/resolv/res_init.c | 19 ++--
lib/libc/resolv/res_mkquery.c | 21 ++-
lib/libc/resolv/res_query.c | 21 ++--
lib/libc/resolv/res_send.c | 41 +++++----
lib/libc/rpc/authunix_prot.c | 7 +-
lib/libc/rpc/bindresvport.c | 8 +-
lib/libc/rpc/clnt_bcast.c | 13 +-
lib/libc/rpc/clnt_vc.c | 116 ++++++++++++-------------
lib/libc/rpc/pmap_rmt.c | 6 +-
lib/libc/rpc/rpc_generic.c | 20 ++-
lib/libc/rpc/rpc_prot.c | 7 +-
lib/libc/rpc/rpcb_clnt.c | 11 +-
lib/libc/rpc/rpcb_st_xdr.c | 20 ++--
lib/libc/rpc/svc_auth_unix.c | 7 +-
lib/libc/rpc/svc_dg.c | 12 +-
lib/libc/rpc/svc_vc.c | 13 +-
lib/libc/rpc/xdr.c | 129 +++++++++-------------------
lib/libc/rpc/xdr_rec.c | 25 +++--
lib/libc/stdio/fflush.c | 9 +-
lib/libc/stdio/fgetwc.c | 7 +-
lib/libc/stdio/fputs.c | 10 +-
lib/libc/stdio/fread.c | 8 +-
lib/libc/stdio/fseeko.c | 10 +-
lib/libc/stdio/fvwrite.c | 33 +++---
lib/libc/stdio/fvwrite.h | 6 +-
lib/libc/stdio/makebuf.c | 7 +-
lib/libc/stdio/setvbuf.c | 13 +-
lib/libc/stdio/snprintf.c | 7 +-
lib/libc/stdio/sscanf.c | 9 +-
lib/libc/stdio/stdio.c | 11 +-
lib/libc/stdio/vfscanf.c | 20 ++--
lib/libc/stdio/vfwprintf.c | 43 ++++++---
lib/libc/stdio/vfwscanf.c | 22 ++--
lib/libc/stdio/vsnprintf.c | 7 +-
lib/libc/stdio/vsnprintf_ss.c | 22 +++-
lib/libc/stdio/vsscanf.c | 9 +-
lib/libc/stdio/vswscanf.c | 8 +-
lib/libc/stdio/wbuf.c | 7 +-
lib/libc/stdlib/l64a.c | 14 +--
lib/libc/stdlib/merge.c | 34 +++----
lib/libc/stdlib/strfmon.c | 13 +-
lib/libc/sys/sched.c | 8 +-
lib/libc/time/localtime.c | 69 +++++++-------
lib/libc/time/strptime.c | 6 +-
lib/libc/yp/xdryp.c | 116 +++++++------------------
135 files changed, 1193 insertions(+), 1050 deletions(-)
diffs (truncated from 7732 to 300 lines):
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/Makefile.inc
--- a/lib/libc/Makefile.inc Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/Makefile.inc Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.8 2012/01/20 16:31:29 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.9 2012/03/13 21:13:30 christos Exp $
# @(#)Makefile 8.2 (Berkeley) 2/3/94
#
# All library objects contain sccsid strings by default; they may be
@@ -24,7 +24,7 @@
.include <bsd.own.mk>
WARNS=4
-CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT
+CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT -D_DIAGNOSTIC
.if (${USE_HESIOD} != "no")
CPPFLAGS+= -DHESIOD
@@ -40,10 +40,8 @@
CPPFLAGS+= -DYP
.endif
-.if ${MACHINE_ARCH} == "i386"
# Set lint to exit on warnings
LINTFLAGS+= -w
-.endif
# ignore 'empty translation unit' warnings.
LINTFLAGS+= -X 272
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/cdb/cdbw.c
--- a/lib/libc/cdb/cdbw.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/cdb/cdbw.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdbw.c,v 1.1 2010/04/25 00:54:46 joerg Exp $ */
+/* $NetBSD: cdbw.c,v 1.2 2012/03/13 21:13:31 christos Exp $ */
/*-
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -36,12 +36,13 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: cdbw.c,v 1.1 2010/04/25 00:54:46 joerg Exp $");
+__RCSID("$NetBSD: cdbw.c,v 1.2 2012/03/13 21:13:31 christos Exp $");
#include "namespace.h"
#include <sys/endian.h>
#include <sys/queue.h>
+#include <assert.h>
#include <cdbw.h>
#include <stdlib.h>
#include <string.h>
@@ -167,7 +168,8 @@
memcpy(cdbw->data_ptr[cdbw->data_counter], data, datalen);
cdbw->data_len[cdbw->data_counter] = datalen;
cdbw->data_size += datalen;
- *idx = cdbw->data_counter++;
+ _DIAGASSERT(__type_fit(uint32_t, cdbw->data_counter));
+ *idx = (uint32_t)cdbw->data_counter++;
return 0;
}
@@ -330,7 +332,9 @@
return;
}
- state->output_order[--state->output_index] = e - state->edges;
+ ptrdiff_t td = e - state->edges;
+ _DIAGASSERT(__type_fit(uint32_t, td));
+ state->output_order[--state->output_index] = (uint32_t)td;
vl = &state->verts[e->left];
vm = &state->verts[e->middle];
@@ -365,8 +369,7 @@
struct key_hash *key_hash;
struct vertex *v;
struct edge *e;
- uint32_t hashes[3];
- size_t i;
+ uint32_t hashes[3], i;
e = state->edges;
for (i = 0; i < cdbw->hash_size; ++i) {
@@ -492,8 +495,10 @@
memcpy(buf, "NBCDB\n\0", 7);
buf[7] = 1;
strncpy((char *)buf + 8, descr, 16);
- le32enc(buf + 24, cdbw->data_size);
- le32enc(buf + 28, cdbw->data_counter);
+ _DIAGASSERT(__type_fit(uint32_t, cdbw->data_size));
+ le32enc(buf + 24, (uint32_t)cdbw->data_size);
+ _DIAGASSERT(__type_fit(uint32_t, cdbw->data_counter));
+ le32enc(buf + 28, (uint32_t)cdbw->data_counter);
le32enc(buf + 32, state->entries);
le32enc(buf + 36, state->seed);
cur_pos = 40;
@@ -504,7 +509,8 @@
le32enc(buf + cur_pos, state->g[i]);
cur_pos += size;
}
- size2 = compute_size(cdbw->data_size);
+ _DIAGASSERT(__type_fit(uint32_t, cdbw->data_counter));
+ size2 = compute_size((uint32_t)cdbw->data_size);
size = size * state->entries % size2;
if (size != 0) {
size = size2 - size;
@@ -516,7 +522,9 @@
COND_FLUSH_BUFFER(4);
le32enc(buf + cur_pos, data_size);
cur_pos += size2;
- data_size += cdbw->data_len[i];
+ _DIAGASSERT(__type_fit(uint32_t,
+ data_size + cdbw->data_len[i]));
+ data_size += (uint32_t)cdbw->data_len[i];
}
COND_FLUSH_BUFFER(4);
le32enc(buf + cur_pos, data_size);
@@ -561,8 +569,10 @@
rv = 0;
- state.keys = cdbw->key_counter;
- state.data_entries = cdbw->data_counter;
+ _DIAGASSERT(__type_fit(uint32_t, cdbw->key_counter));
+ state.keys = (uint32_t)cdbw->key_counter;
+ _DIAGASSERT(__type_fit(uint32_t, cdbw->key_counter));
+ state.data_entries = (uint32_t)cdbw->data_counter;
state.entries = state.keys + (state.keys + 3) / 4;
if (state.entries < 10)
state.entries = 10;
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/citrus/citrus_memstream.c
--- a/lib/libc/citrus/citrus_memstream.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/citrus/citrus_memstream.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $ */
+/* $NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_memstream.c,v 1.4 2009/02/03 05:02:12 lukem Exp $");
+__RCSID("$NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -46,7 +46,7 @@
_citrus_memory_stream_getln(struct _citrus_memory_stream * __restrict ms,
size_t * __restrict rlen)
{
- int i;
+ size_t i;
const uint8_t *h, *p;
size_t ret;
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/compat/db/hash/compat_ndbmdatum.c
--- a/lib/libc/compat/db/hash/compat_ndbmdatum.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/compat/db/hash/compat_ndbmdatum.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_ndbmdatum.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */
+/* $NetBSD: compat_ndbmdatum.c,v 1.2 2012/03/13 21:13:31 christos Exp $ */
/*
* Written by Klaus Klein <kleink%NetBSD.org@localhost>, April 28, 2004.
@@ -28,4 +28,6 @@
" include <ndbm.h> for correct reference")
#define datum datum12
+#define datum_truncate(a) ((a) > INT_MAX ? INT_MAX : (int)(a))
+
#include "db/hash/ndbmdatum.c"
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/compat/gen/compat___fts13.c
--- a/lib/libc/compat/gen/compat___fts13.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/compat/gen/compat___fts13.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat___fts13.c,v 1.6 2009/10/19 17:52:01 christos Exp $ */
+/* $NetBSD: compat___fts13.c,v 1.7 2012/03/13 21:13:31 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
@@ -33,6 +33,11 @@
#define __fts_dev_t uint32_t
#define __fts_level_t short
+#ifndef fts_namelen_truncate
+#define fts_namelen_truncate(a) \
+ ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a))
+#endif
+
#define stat __stat13
#define lstat __lstat13
#define fstat __fstat13
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/compat/gen/compat___fts30.c
--- a/lib/libc/compat/gen/compat___fts30.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/compat/gen/compat___fts30.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat___fts30.c,v 1.3 2009/10/19 17:52:04 christos Exp $ */
+/* $NetBSD: compat___fts30.c,v 1.4 2012/03/13 21:13:31 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
@@ -36,6 +36,11 @@
#define lstat __lstat30
#define fstat __fstat30
+#ifndef fts_namelen_truncate
+#define fts_namelen_truncate(a) \
+ ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a))
+#endif
+
#undef fts_children
#define fts_children __fts_children30
#undef fts_close
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/compat/gen/compat___fts31.c
--- a/lib/libc/compat/gen/compat___fts31.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/compat/gen/compat___fts31.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat___fts31.c,v 1.2 2009/10/19 17:52:05 christos Exp $ */
+/* $NetBSD: compat___fts31.c,v 1.3 2012/03/13 21:13:31 christos Exp $ */
#include "namespace.h"
#include <sys/cdefs.h>
@@ -31,6 +31,11 @@
#define __fts_dev_t uint32_t
#define __fts_level_t short
+#ifndef fts_namelen_truncate
+#define fts_namelen_truncate(a) \
+ ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a))
+#endif
+
#define stat __stat30
#define lstat __lstat30
#define fstat __fstat30
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/compat/sys/compat_getdents.c
--- a/lib/libc/compat/sys/compat_getdents.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/compat/sys/compat_getdents.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_getdents.c,v 1.4 2011/06/20 09:11:17 mrg Exp $ */
+/* $NetBSD: compat_getdents.c,v 1.5 2012/03/13 21:13:32 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_getdents.c,v 1.4 2011/06/20 09:11:17 mrg Exp $");
+__RCSID("$NetBSD: compat_getdents.c,v 1.5 2012/03/13 21:13:32 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#define __LIBC12_SOURCE__
@@ -52,6 +52,7 @@
struct dirent12 *odp;
ino_t ino;
int rv;
+ size_t len;
if ((rv = __getdents30(fd, buf, nbytes)) == -1)
return rv;
@@ -78,8 +79,12 @@
odp->d_type = ndp->d_type;
(void)memcpy(odp->d_name, ndp->d_name, (size_t)odp->d_namlen);
odp->d_name[odp->d_namlen] = '\0';
- odp->d_reclen = _DIRENT_SIZE(odp);
+ len = _DIRENT_SIZE(odp);
+ _DIAGASSERT(__type_fit(uint16_t, len));
+ odp->d_reclen = (uint16_t)len;
odp = _DIRENT_NEXT(odp);
}
- return ((char *)(void *)odp) - buf;
+ ptrdiff_t td = (((char *)(void *)odp) - buf);
+ _DIAGASSERT(__type_fit(int, td));
+ return (int)td;
}
diff -r 1419685be18a -r 8d167eea3cbe lib/libc/compat/sys/compat_sigaltstack.c
--- a/lib/libc/compat/sys/compat_sigaltstack.c Tue Mar 13 21:07:28 2012 +0000
+++ b/lib/libc/compat/sys/compat_sigaltstack.c Tue Mar 13 21:13:30 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat_sigaltstack.c,v 1.3 2009/01/11 02:46:26 christos Exp $ */
+/* $NetBSD: compat_sigaltstack.c,v 1.4 2012/03/13 21:13:32 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: compat_sigaltstack.c,v 1.3 2009/01/11 02:46:26 christos Exp $");
+__RCSID("$NetBSD: compat_sigaltstack.c,v 1.4 2012/03/13 21:13:32 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#define __LIBC12_SOURCE__
@@ -62,7 +62,7 @@
if (oss.ss_size > INT_MAX)
ooss->ss_size = INT_MAX;
else
Home |
Main Index |
Thread Index |
Old Index