Lint warnings.

This commit is contained in:
elad 2005-08-27 16:55:59 +00:00
parent df49fbe1c2
commit 232f61fabb
9 changed files with 48 additions and 41 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: getmaxpartitions.c,v 1.4 2000/07/05 11:46:40 ad Exp $ */
/* $NetBSD: getmaxpartitions.c,v 1.5 2005/08/27 17:23:17 elad Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: getmaxpartitions.c,v 1.4 2000/07/05 11:46:40 ad Exp $");
__RCSID("$NetBSD: getmaxpartitions.c,v 1.5 2005/08/27 17:23:17 elad Exp $");
#endif
#include <sys/param.h>
@ -54,7 +54,7 @@ getmaxpartitions(void)
mib[0] = CTL_KERN;
mib[1] = KERN_MAXPARTITIONS;
varlen = sizeof(maxpart);
if (sysctl(mib, 2, &maxpart, &varlen, NULL, 0) < 0)
if (sysctl(mib, 2, &maxpart, &varlen, NULL, (size_t)0) < 0)
return (-1);
return (maxpart);

View File

@ -1,4 +1,4 @@
/* $NetBSD: getrawpartition.c,v 1.4 1999/07/02 15:49:12 simonb Exp $ */
/* $NetBSD: getrawpartition.c,v 1.5 2005/08/27 17:23:29 elad Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: getrawpartition.c,v 1.4 1999/07/02 15:49:12 simonb Exp $");
__RCSID("$NetBSD: getrawpartition.c,v 1.5 2005/08/27 17:23:29 elad Exp $");
#endif
#include <sys/param.h>
@ -54,7 +54,7 @@ getrawpartition()
mib[0] = CTL_KERN;
mib[1] = KERN_RAWPARTITION;
varlen = sizeof(rawpart);
if (sysctl(mib, 2, &rawpart, &varlen, NULL, 0) < 0)
if (sysctl(mib, 2, &rawpart, &varlen, NULL, (size_t)0) < 0)
return (-1);
return (rawpart);

View File

@ -1,4 +1,4 @@
/* $NetBSD: login_cap.c,v 1.21 2005/04/13 20:32:42 drochner Exp $ */
/* $NetBSD: login_cap.c,v 1.22 2005/08/27 17:24:42 elad Exp $ */
/*-
* Copyright (c) 1995,1997 Berkeley Software Design, Inc. All rights reserved.
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: login_cap.c,v 1.21 2005/04/13 20:32:42 drochner Exp $");
__RCSID("$NetBSD: login_cap.c,v 1.22 2005/08/27 17:24:42 elad Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -574,7 +574,7 @@ setusercontext(login_cap_t *lc, struct passwd *pwd, uid_t uid, u_int flags)
/* XXX - call syslog()? */;
if (flags & LOGIN_SETPRIORITY) {
p = login_getcapnum(lc, "priority", 0LL, 0LL);
p = login_getcapnum(lc, "priority", (quad_t)0, (quad_t)0);
if (setpriority(PRIO_PROCESS, 0, (int)p) < 0)
syslog(LOG_ERR, "%s: setpriority: %m", lc->lc_class);

View File

@ -1,4 +1,4 @@
/* $NetBSD: logout.c,v 1.15 2003/08/07 16:44:59 agc Exp $ */
/* $NetBSD: logout.c,v 1.16 2005/08/27 17:07:17 elad Exp $ */
/*
* Copyright (c) 1988, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: logout.c,v 1.15 2003/08/07 16:44:59 agc Exp $");
__RCSID("$NetBSD: logout.c,v 1.16 2005/08/27 17:07:17 elad Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -62,10 +62,11 @@ logout(const char *line)
return(0);
rval = 0;
while (read(fd, &ut, sizeof(ut)) == sizeof(ut)) {
if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE))
if (!ut.ut_name[0] || strncmp(ut.ut_line, line,
(size_t)UT_LINESIZE))
continue;
memset(ut.ut_name, 0, UT_NAMESIZE);
memset(ut.ut_host, 0, UT_HOSTSIZE);
memset(ut.ut_name, 0, (size_t)UT_NAMESIZE);
memset(ut.ut_host, 0, (size_t)UT_HOSTSIZE);
(void)time(&ut.ut_time);
(void)lseek(fd, -(off_t)sizeof(ut), SEEK_CUR);
(void)write(fd, &ut, sizeof(ut));

View File

@ -1,4 +1,4 @@
/* $NetBSD: pidlock.c,v 1.12 2003/07/26 19:25:10 salo Exp $ */
/* $NetBSD: pidlock.c,v 1.13 2005/08/27 16:55:59 elad Exp $ */
/*
* Copyright 1996, 1997 by Curt Sampson <cjs@NetBSD.org>.
@ -24,7 +24,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: pidlock.c,v 1.12 2003/07/26 19:25:10 salo Exp $");
__RCSID("$NetBSD: pidlock.c,v 1.13 2005/08/27 16:55:59 elad Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@ -84,7 +84,7 @@ pidlock(const char *lockfile, int flags, pid_t *locker, const char *info)
return -1;
}
snprintf(s, sizeof(s), "%10d\n", getpid()); /* pid */
if (write(f, s, 11) != 11) {
if (write(f, s, (size_t)11) != 11) {
err = errno;
close(f);
unlink(tempfile);
@ -93,7 +93,7 @@ pidlock(const char *lockfile, int flags, pid_t *locker, const char *info)
}
if ((flags & PIDLOCK_USEHOSTNAME)) { /* hostname */
if ((write(f, hostname, strlen(hostname)) != strlen(hostname))
|| (write(f, "\n", 1) != 1)) {
|| (write(f, "\n", (size_t)1) != 1)) {
err = errno;
close(f);
unlink(tempfile);
@ -104,7 +104,7 @@ pidlock(const char *lockfile, int flags, pid_t *locker, const char *info)
if (info) { /* info */
if (!(flags & PIDLOCK_USEHOSTNAME)) {
/* write blank line because there's no hostname */
if (write(f, "\n", 1) != 1) {
if (write(f, "\n", (size_t)1) != 1) {
err = errno;
close(f);
unlink(tempfile);
@ -113,7 +113,7 @@ pidlock(const char *lockfile, int flags, pid_t *locker, const char *info)
}
}
if (write(f, info, strlen(info)) != strlen(info) ||
(write(f, "\n", 1) != 1)) {
(write(f, "\n", (size_t)1) != 1)) {
err = errno;
close(f);
unlink(tempfile);
@ -135,7 +135,7 @@ lockfailed:
}
/* Find out who has this lockfile. */
if ((f = open(lockfile, O_RDONLY, 0)) != 0) {
read(f, s, 11);
read(f, s, (size_t)11);
pid2 = atoi(s);
read(f, s, sizeof(s)-2);
s[sizeof(s)-1] = '\0';

View File

@ -1,4 +1,4 @@
/* $NetBSD: snprintb.c,v 1.4 2004/12/11 06:41:16 christos Exp $ */
/* $NetBSD: snprintb.c,v 1.5 2005/08/27 17:28:26 elad Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: snprintb.c,v 1.4 2004/12/11 06:41:16 christos Exp $");
__RCSID("$NetBSD: snprintb.c,v 1.5 2005/08/27 17:28:26 elad Exp $");
#endif
/*
@ -127,7 +127,8 @@ snprintb(buf, buflen, bitfmt, val)
case 'f':
case 'F':
flen = *bitfmt++; /* field length */
field = (val >> bit) & ((1ULL << flen) - 1);
field = (val >> bit) &
(((uint64_t)1 << flen) - 1);
if (ch == 'F') /* just extract */
break;
PUTC(sep);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sockaddr_snprintf.c,v 1.5 2005/04/09 02:05:47 atatat Exp $ */
/* $NetBSD: sockaddr_snprintf.c,v 1.6 2005/08/27 17:01:49 elad Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.5 2005/04/09 02:05:47 atatat Exp $");
__RCSID("$NetBSD: sockaddr_snprintf.c,v 1.6 2005/08/27 17:01:49 elad Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -121,7 +121,8 @@ sockaddr_snprintf(char *buf, size_t len, const char *fmt,
name = addr;
if (a && getnameinfo(sa, (socklen_t)sa->sa_len, addr = abuf,
sizeof(abuf), NULL, 0, NI_NUMERICHOST|NI_NUMERICSERV) != 0)
(unsigned int)sizeof(abuf), NULL, 0,
NI_NUMERICHOST|NI_NUMERICSERV) != 0)
return -1;
for (ptr = fmt; *ptr; ptr++) {
@ -159,7 +160,8 @@ sockaddr_snprintf(char *buf, size_t len, const char *fmt,
ADDNA();
else {
getnameinfo(sa, (socklen_t)sa->sa_len,
name = Abuf, sizeof(nbuf), NULL, 0, 0);
name = Abuf,
(unsigned int)sizeof(nbuf), NULL, 0, 0);
ADDS(name);
}
break;
@ -170,7 +172,8 @@ sockaddr_snprintf(char *buf, size_t len, const char *fmt,
ADDNA();
else {
getnameinfo(sa, (socklen_t)sa->sa_len, NULL, 0,
port = pbuf, sizeof(pbuf), 0);
port = pbuf,
(unsigned int)sizeof(pbuf), 0);
ADDS(port);
}
break;
@ -226,5 +229,5 @@ sockaddr_snprintf(char *buf, size_t len, const char *fmt,
}
done:
ADDN();
return buf - sbuf;
return (int)(buf - sbuf);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ttyaction.c,v 1.17 2004/12/11 06:41:16 christos Exp $ */
/* $NetBSD: ttyaction.c,v 1.18 2005/08/27 17:06:29 elad Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: ttyaction.c,v 1.17 2004/12/11 06:41:16 christos Exp $");
__RCSID("$NetBSD: ttyaction.c,v 1.18 2005/08/27 17:06:29 elad Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -93,7 +93,7 @@ ttyaction(const char *tty, const char *act, const char *user)
return 0;
/* Skip the "/dev/" part of the first arg. */
if (!strncmp(tty, "/dev/", 5))
if (!strncmp(tty, "/dev/", (size_t)5))
tty += 5;
/* Args will be: "sh -c ..." */
@ -116,7 +116,7 @@ ttyaction(const char *tty, const char *act, const char *user)
linenum = 0;
status = 0;
while (fgets(line, sizeof(line), fp)) {
while (fgets(line, (int)sizeof(line), fp)) {
linenum++;
/* Allow comment lines. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ttymsg.c,v 1.21 2005/01/08 06:43:16 christos Exp $ */
/* $NetBSD: ttymsg.c,v 1.22 2005/08/27 17:16:06 elad Exp $ */
/*
* Copyright (c) 1989, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)ttymsg.c 8.2 (Berkeley) 11/16/93";
#else
__RCSID("$NetBSD: ttymsg.c,v 1.21 2005/01/08 06:43:16 christos Exp $");
__RCSID("$NetBSD: ttymsg.c,v 1.22 2005/08/27 17:16:06 elad Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -66,10 +66,11 @@ ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout)
static char errbuf[1024];
char device[MAXNAMLEN];
const char *ptr;
int cnt, fd, left, wret;
int fd, ret;
struct iovec localiov[32];
sigset_t nset;
int forked = 0;
size_t cnt, left, wret;
_DIAGASSERT(iov != NULL);
_DIAGASSERT(iovcnt >= 0);
@ -82,19 +83,20 @@ ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout)
return errbuf;
}
ptr = strncmp(line, "pts/", 4) == 0 ? line + 4 : line;
ptr = strncmp(line, "pts/", (size_t)4) == 0 ? line + 4 : line;
if (strcspn(ptr, "./") != strlen(ptr)) {
/* A slash or dot is an attempt to break security... */
(void)snprintf(errbuf, sizeof(errbuf),
"%s: '/' or '.' in \"%s\"", __func__, line);
return errbuf;
}
cnt = snprintf(device, sizeof(device), "%s%s", _PATH_DEV, line);
if (cnt == -1 || cnt >= sizeof(device)) {
ret = snprintf(device, sizeof(device), "%s%s", _PATH_DEV, line);
if (ret == -1 || ret >= (int)sizeof(device)) {
(void) snprintf(errbuf, sizeof(errbuf),
"%s: line `%s' too long", __func__, line);
return errbuf;
}
cnt = (size_t)ret;
/*
* open will fail on slip lines or exclusive-use lines
@ -142,7 +144,7 @@ ttymsg(struct iovec *iov, int iovcnt, const char *line, int tmout)
continue;
} else if (wret == 0) {
(void)snprintf(errbuf, sizeof(errbuf),
"%s: failed writing %d bytes to `%s'", __func__,
"%s: failed writing %zu bytes to `%s'", __func__,
left, device);
(void) close(fd);
if (forked)