Module Name: src Committed By: christos Date: Sat Oct 17 22:26:13 UTC 2009
Modified Files: src/usr.sbin/sup/source: expand.c ffilecopy.c filecopy.c netcryptvoid.c scm.c scmio.c stree.c supextern.h supmsg.c Log Message: pass lint To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/sup/source/expand.c \ src/usr.sbin/sup/source/scmio.c cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sup/source/ffilecopy.c \ src/usr.sbin/sup/source/netcryptvoid.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/sup/source/filecopy.c cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sup/source/scm.c cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/sup/source/stree.c cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/sup/source/supextern.h cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/sup/source/supmsg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/sup/source/expand.c diff -u src/usr.sbin/sup/source/expand.c:1.17 src/usr.sbin/sup/source/expand.c:1.18 --- src/usr.sbin/sup/source/expand.c:1.17 Tue Oct 13 08:11:19 2009 +++ src/usr.sbin/sup/source/expand.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.c,v 1.17 2009/10/13 12:11:19 christos Exp $ */ +/* $NetBSD: expand.c,v 1.18 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -97,7 +97,7 @@ static int amatch(char *, char *); static void addone(char *, const char *); static int addpath(char); -static int gethdir(char *, int); +static int gethdir(char *, size_t); int expand(char *spec, char **buffer, int bufsize) @@ -392,7 +392,7 @@ } static int -gethdir(char *home, int homelen) +gethdir(char *home, size_t homelen) { struct passwd *pp = getpwnam(home); Index: src/usr.sbin/sup/source/scmio.c diff -u src/usr.sbin/sup/source/scmio.c:1.17 src/usr.sbin/sup/source/scmio.c:1.18 --- src/usr.sbin/sup/source/scmio.c:1.17 Fri Oct 16 08:41:37 2009 +++ src/usr.sbin/sup/source/scmio.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: scmio.c,v 1.17 2009/10/16 12:41:37 christos Exp $ */ +/* $NetBSD: scmio.c,v 1.18 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -157,6 +157,7 @@ #include "libc.h" #include <errno.h> +#include <stdbool.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/file.h> @@ -201,9 +202,9 @@ } buffers[2]; struct buf *gblbufptr; /* buffer pointer */ -static int writedata(int, char *); -static int writeblock(int, char *); -static int readdata(int, char *); +static int writedata(size_t, void *); +static int writeblock(size_t, void *); +static int readdata(size_t, void *, bool); static int readcount(int *); @@ -212,7 +213,7 @@ ***********************************************/ static int -writedata(int count, char *data) +writedata(size_t count, void *data) { /* write raw data to network */ int x, tries; struct buf *bp; @@ -260,12 +261,12 @@ } static int -writeblock(int count, char *data) +writeblock(size_t count, void *data) { /* write data block */ int x; - int y = byteswap(count); + int y = byteswap((int)count); - x = writedata(sizeof(int), (char *) &y); + x = writedata(sizeof(int), &y); if (x == SCMOK) x = writedata(count, data); return (x); @@ -284,18 +285,18 @@ gblbufptr->b_ptr = gblbufptr->b_data; gblbufptr->b_cnt = 0; x = byteswap(msg); - return (writedata(sizeof(int), (char *) &x)); + return (writedata(sizeof(int), &x)); } int writemend(void) { /* write end of message */ - int count; + size_t count; char *data; int x; x = byteswap(ENDCOUNT); - x = writedata(sizeof(int), (char *) &x); + x = writedata(sizeof(int), &x); if (x != SCMOK) return (x); if (gblbufptr == NULL) @@ -317,18 +318,19 @@ if (scmdebug > 2) loginfo("SCM Writing integer %d", i); x = byteswap(i); - return (writeblock(sizeof(int), (char *) &x)); + return (writeblock(sizeof(int), &x)); } int writestring(char *p) { /* write string as data block */ - int len, x; + int len; + int x; if (p == NULL) { int y = byteswap(NULLCOUNT); if (scmdebug > 2) loginfo("SCM Writing string NULL"); - return (writedata(sizeof(int), (char *) &y)); + return (writedata(sizeof(int), &y)); } if (scmdebug > 2) loginfo("SCM Writing string %s", p); @@ -340,7 +342,7 @@ encode(p, cryptbuf, len); p = cryptbuf; } - return (writeblock(len, p)); + return (writeblock((size_t)len, p)); } int @@ -353,9 +355,9 @@ if (fstat(f, &statbuf) < 0) return (scmerr(errno, "Can't access open file for message")); - filesize = statbuf.st_size; + filesize = (int)statbuf.st_size; y = byteswap(filesize); - x = writedata(sizeof(int), (char *) &y); + x = writedata(sizeof(int), &y); if (cryptflag) x = getcryptbuf(FILEXFER); @@ -367,9 +369,9 @@ if (number > 0) { if (cryptflag) { encode(buf, cryptbuf, number); - x = writedata(number, cryptbuf); + x = writedata((size_t)number, cryptbuf); } else { - x = writedata(number, buf); + x = writedata((size_t)number, buf); } sum += number; } @@ -420,7 +422,7 @@ *************************************************/ static int -readdata(int count, char *data) +readdata(size_t count, void *vdata, bool push) { /* read raw data from network */ char *p; int c, n, m, x; @@ -428,12 +430,13 @@ static char *bufptr; static char buffer[FILEXFER]; struct pollfd set[1]; + char *data = vdata; - if (count < 0) { + if (push) { if (bufptr + count < buffer) return (scmerr(-1, "No space in buffer %d", count)); - bufptr += count; - bufcnt -= count; + bufptr -= count; + bufcnt += count; memcpy(bufptr, data, -count); return (SCMOK); } @@ -448,7 +451,7 @@ return (SCMOK); } if (bufcnt > 0) { - memcpy(data, bufptr, bufcnt); + memcpy(data, bufptr, (size_t)bufcnt); data += bufcnt; count -= bufcnt; } @@ -466,7 +469,7 @@ if (errno != EINTR) sleep(5); } - x = read(netfile, p, n); + x = read(netfile, p, (size_t)n); if (x == 0) return (scmerr(-1, "Premature EOF on network input")); if (x < 0) @@ -476,7 +479,7 @@ m -= x; bufcnt += x; } - memcpy(data, bufptr, count); + memcpy(data, bufptr, (size_t)count); bufptr += count; bufcnt -= count; return (SCMOK); @@ -487,7 +490,7 @@ { /* read count of data block */ int x; int y; - x = readdata(sizeof(int), (char *) &y); + x = readdata(sizeof(int), &y, false); if (x != SCMOK) return (x); *count = byteswap(y); @@ -499,10 +502,10 @@ { /* preread count of data block */ int x; int y; - x = readdata(sizeof(int), (char *) &y); + x = readdata(sizeof(int), &y, false); if (x != SCMOK) return (x); - x = readdata(-((int) (sizeof(int))), (char *) &y); + x = readdata(sizeof(int), &y, true); if (x != SCMOK) return (x); *count = byteswap(y); @@ -512,7 +515,7 @@ int readflush(void) { - return (readdata(0, (char *) NULL)); + return readdata(0, NULL, false); } int @@ -523,7 +526,7 @@ int m; if (scmdebug > 1) loginfo("SCM Reading message %d", msg); - x = readdata(sizeof(int), (char *) &m); /* msg type */ + x = readdata(sizeof(int), &m, false); /* msg type */ if (x != SCMOK) return (x); m = byteswap(m); @@ -547,7 +550,7 @@ { int x; int y; - x = readdata(sizeof(int), (char *) &y); + x = readdata(sizeof(int), &y, false); y = byteswap(y); if (x == SCMOK && y != ENDCOUNT) return (scmerr(-1, "Error reading end of message")); @@ -566,7 +569,7 @@ if (n < 0) return (scmerr(-1, "Invalid message count %d", n)); while (x == SCMOK && n > 0) { - x = readdata(XFERSIZE(n), buf); + x = readdata((size_t)XFERSIZE(n), buf, false); n -= XFERSIZE(n); } return (x); @@ -584,7 +587,7 @@ return (scmerr(-1, "Invalid message count %d", y)); if (y != sizeof(int)) return (scmerr(-1, "Size error for int message is %d", y)); - x = readdata(sizeof(int), (char *) &y); + x = readdata(sizeof(int), &y, false); (*buf) = byteswap(y); if (scmdebug > 2) loginfo("SCM Reading integer %d", *buf); @@ -616,7 +619,7 @@ if (cryptflag) { x = getcryptbuf(count + 1); if (x == SCMOK) - x = readdata(count, cryptbuf); + x = readdata((size_t)count, cryptbuf, false); if (x != SCMOK) { free(p); return (x); @@ -625,7 +628,7 @@ printf("SCM Reading encrypted string %s\n", cryptbuf); decode(cryptbuf, p, count); } else { - x = readdata(count, p); + x = readdata((size_t)count, p, false); if (x != SCMOK) { free(p); return (x); @@ -657,13 +660,13 @@ return (scmerr(-1, "Invalid message count %d", count)); while (x == SCMOK && count > 0) { if (cryptflag) { - x = readdata(XFERSIZE(count), cryptbuf); + x = readdata((size_t)XFERSIZE(count), cryptbuf, false); if (x == SCMOK) decode(cryptbuf, buf, XFERSIZE(count)); } else - x = readdata(XFERSIZE(count), buf); + x = readdata((size_t)XFERSIZE(count), buf, false); if (x == SCMOK) { - (void) write(f, buf, XFERSIZE(count)); + (void) write(f, buf, (size_t)XFERSIZE(count)); count -= XFERSIZE(count); } } @@ -736,7 +739,7 @@ if (c <= 0) { break; } - (void) write(1, buf, c); + (void) write(1, buf, (size_t)c); } } if (set[0].revents & POLLIN) { @@ -746,7 +749,7 @@ else { if (c <= 0) break; - (void) write(netfile, buf, c); + (void) write(netfile, buf, (size_t)c); } } } Index: src/usr.sbin/sup/source/ffilecopy.c diff -u src/usr.sbin/sup/source/ffilecopy.c:1.9 src/usr.sbin/sup/source/ffilecopy.c:1.10 --- src/usr.sbin/sup/source/ffilecopy.c:1.9 Fri May 30 10:19:57 2008 +++ src/usr.sbin/sup/source/ffilecopy.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ffilecopy.c,v 1.9 2008/05/30 14:19:57 christos Exp $ */ +/* $NetBSD: ffilecopy.c,v 1.10 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -44,7 +44,7 @@ # define FBUF_HACK(here,there) \ do { \ if ((here)->_r > 0) { \ - i = write(therefile, (here)->_p, (here)->_r); \ + i = write(therefile, (here)->_p, (size_t)(here)->_r); \ if (i != (here)->_r) \ return EOF; \ (here)->_p = (here)->_bf._base; \ Index: src/usr.sbin/sup/source/netcryptvoid.c diff -u src/usr.sbin/sup/source/netcryptvoid.c:1.9 src/usr.sbin/sup/source/netcryptvoid.c:1.10 --- src/usr.sbin/sup/source/netcryptvoid.c:1.9 Wed Dec 20 11:33:34 2006 +++ src/usr.sbin/sup/source/netcryptvoid.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: netcryptvoid.c,v 1.9 2006/12/20 16:33:34 christos Exp $ */ +/* $NetBSD: netcryptvoid.c,v 1.10 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -68,6 +68,7 @@ } int +/*ARGSUSED*/ getcryptbuf(int x __unused) { if (cryptflag == 0) { @@ -77,12 +78,14 @@ } void +/*ARGSUSED*/ decode(char *in __unused, char *out __unused, int count __unused) { } void +/*ARGSUSED*/ encode(char *in __unused, char *out __unused, int count __unused) { } Index: src/usr.sbin/sup/source/filecopy.c diff -u src/usr.sbin/sup/source/filecopy.c:1.4 src/usr.sbin/sup/source/filecopy.c:1.5 --- src/usr.sbin/sup/source/filecopy.c:1.4 Wed Jul 10 16:19:39 2002 +++ src/usr.sbin/sup/source/filecopy.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: filecopy.c,v 1.4 2002/07/10 20:19:39 wiz Exp $ */ +/* $NetBSD: filecopy.c,v 1.5 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1991 Carnegie Mellon University @@ -57,13 +57,13 @@ #include "supcdefs.h" #include "supextern.h" -int +ssize_t filecopy(int here, int there) { - int kount; + ssize_t kount; char buffer[BUFFERSIZE]; kount = 0; while (kount == 0 && (kount = read(here, buffer, BUFFERSIZE)) > 0) - kount -= write(there, buffer, kount); + kount -= write(there, buffer, (size_t)kount); return (kount ? -1 : 0); } Index: src/usr.sbin/sup/source/scm.c diff -u src/usr.sbin/sup/source/scm.c:1.27 src/usr.sbin/sup/source/scm.c:1.28 --- src/usr.sbin/sup/source/scm.c:1.27 Fri Oct 16 08:41:37 2009 +++ src/usr.sbin/sup/source/scm.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: scm.c,v 1.27 2009/10/16 12:41:37 christos Exp $ */ +/* $NetBSD: scm.c,v 1.28 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -263,7 +263,7 @@ continue; } if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, - (char *) &one, sizeof(int)) < 0) { + &one, sizeof(int)) < 0) { cause = "setsockopt(SO_REUSEADDR)"; close(sock); continue; @@ -296,7 +296,7 @@ remotename = NULL; len = sizeof(from); do { - netfile = accept(sock, (struct sockaddr *) & from, &len); + netfile = accept(sock, (struct sockaddr *)(void *)&from, &len); } while (netfile < 0 && errno == EINTR); if (netfile < 0) return (scmerr(errno, "Can't accept connections")); @@ -305,7 +305,7 @@ return (scmerr(errno, "Can't accept connections")); } memcpy(&remoteaddr, &from, len); - if (read(netfile, (char *) &x, sizeof(int)) != sizeof(int)) + if (read(netfile, &x, sizeof(int)) != sizeof(int)) return (scmerr(errno, "Can't transmit data on connection")); if (x == 0x01020304) swapmode = 0; @@ -369,7 +369,7 @@ return (0); s = *b * 30; if (gettimeofday(&tt, (struct timezone *) NULL) >= 0) - s += (tt.tv_usec >> 8) % s; + s += ((uint32_t)tt.tv_usec >> 8) % s; if (*b < 32) *b <<= 1; if (*t != -1) { @@ -411,7 +411,7 @@ gai_strerror(error))); } backoff = 1; - while (1) { + for (;;) { netfile = -1; for (res = res0; res; res = res->ai_next) { if (res->ai_addrlen > sizeof(remoteaddr)) @@ -445,7 +445,7 @@ memcpy(&remoteaddr, res->ai_addr, res->ai_addrlen); remotename = estrdup(hostname); x = 0x01020304; - (void) write(netfile, (char *) &x, sizeof(int)); + (void) write(netfile, &x, sizeof(int)); swapmode = 0; /* swap only on server, not client */ freeaddrinfo(res0); return (SCMOK); @@ -492,9 +492,9 @@ char h1[NI_MAXHOST]; if (remotename == NULL) { - if (getnameinfo((struct sockaddr *) & remoteaddr, + if (getnameinfo((struct sockaddr *)(void *)&remoteaddr, #ifdef BSD4_4 - remoteaddr.ss_len, + (socklen_t)remoteaddr.ss_len, #else sizeof(struct sockaddr), #endif @@ -586,9 +586,9 @@ char h1[NI_MAXHOST], h2[NI_MAXHOST]; const int niflags = NI_NUMERICHOST; - if (getnameinfo((struct sockaddr *) &remoteaddr, + if (getnameinfo((struct sockaddr *)(void *)&remoteaddr, #ifdef BSD4_4 - remoteaddr.ss_len, + (socklen_t)remoteaddr.ss_len, #else sizeof(struct sockaddr), #endif @@ -601,7 +601,7 @@ continue; if (getnameinfo(ifa->ifa_addr, #ifdef BSD4_4 - ifa->ifa_addr->sa_len, + (socklen_t)ifa->ifa_addr->sa_len, #else sizeof(struct sockaddr), #endif @@ -623,9 +623,9 @@ const int niflags = NI_NUMERICHOST; struct addrinfo hints, *res0, *res; - if (getnameinfo((struct sockaddr *) & remoteaddr, + if (getnameinfo((struct sockaddr *)(void *)&remoteaddr, #ifdef BSD4_4 - remoteaddr.ss_len, + (socklen_t)remoteaddr.ss_len, #else sizeof(struct sockaddr), #endif Index: src/usr.sbin/sup/source/stree.c diff -u src/usr.sbin/sup/source/stree.c:1.14 src/usr.sbin/sup/source/stree.c:1.15 --- src/usr.sbin/sup/source/stree.c:1.14 Sat Oct 17 16:46:03 2009 +++ src/usr.sbin/sup/source/stree.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: stree.c,v 1.14 2009/10/17 20:46:03 christos Exp $ */ +/* $NetBSD: stree.c,v 1.15 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -338,6 +338,7 @@ } static int +/*ARGSUSED*/ Tprintone(TREE * t, void *v __unused) { int i; Index: src/usr.sbin/sup/source/supextern.h diff -u src/usr.sbin/sup/source/supextern.h:1.21 src/usr.sbin/sup/source/supextern.h:1.22 --- src/usr.sbin/sup/source/supextern.h:1.21 Fri Oct 16 08:41:37 2009 +++ src/usr.sbin/sup/source/supextern.h Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: supextern.h,v 1.21 2009/10/16 12:41:37 christos Exp $ */ +/* $NetBSD: supextern.h,v 1.22 2009/10/17 22:26:13 christos Exp $ */ struct stat; @@ -9,10 +9,10 @@ int expand(char *, char **, int); /* ffilecopy.c */ -int ffilecopy(FILE *, FILE *); +ssize_t ffilecopy(FILE *, FILE *); /* filecopy.c */ -int filecopy(int, int ); +ssize_t filecopy(int, int ); /* log.c */ void logopen(char *); Index: src/usr.sbin/sup/source/supmsg.c diff -u src/usr.sbin/sup/source/supmsg.c:1.16 src/usr.sbin/sup/source/supmsg.c:1.17 --- src/usr.sbin/sup/source/supmsg.c:1.16 Fri Oct 16 08:41:37 2009 +++ src/usr.sbin/sup/source/supmsg.c Sat Oct 17 18:26:13 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: supmsg.c,v 1.16 2009/10/16 12:41:37 christos Exp $ */ +/* $NetBSD: supmsg.c,v 1.17 2009/10/17 22:26:13 christos Exp $ */ /* * Copyright (c) 1992 Carnegie Mellon University @@ -323,6 +323,7 @@ extern TREE *refuseT; /* tree of files to refuse */ static int +/*ARGSUSED*/ refuseone(TREE * t, void *v __unused) { return (writestring(t->Tname)); @@ -365,6 +366,7 @@ extern time_t scantime; /* time that collection was scanned */ static int +/*ARGSUSED*/ listone(TREE * t, void *v __unused) { int x; @@ -430,6 +432,7 @@ extern TREE *needT; /* tree of files to need */ static int +/*ARGSUSED*/ needone(TREE * t, void *v __unused) { int x; @@ -481,6 +484,7 @@ extern TREE *denyT; /* tree of files to deny */ static int +/*ARGSUSED*/ denyone(TREE * t, void *v __unused) { return (writestring(t->Tname)); @@ -532,6 +536,7 @@ extern TREE *upgradeT; /* pointer to file being upgraded */ static int +/*ARGSUSED*/ writeone(TREE * t, void *v __unused) { return (writestring(t->Tname));