diff options
author | markm <markm@FreeBSD.org> | 2002-02-22 20:51:00 +0000 |
---|---|---|
committer | markm <markm@FreeBSD.org> | 2002-02-22 20:51:00 +0000 |
commit | 7b7558d88436331476243b0b668d2e257d7687fe (patch) | |
tree | ba3cea9a04974b56b589e2a934d2f4ae56780dce /bin | |
parent | f24931e332589b25b779130a37d5f3491e609025 (diff) | |
download | FreeBSD-src-7b7558d88436331476243b0b668d2e257d7687fe.zip FreeBSD-src-7b7558d88436331476243b0b668d2e257d7687fe.tar.gz |
Fix warnings inspired by lint, a commercial lint and WARNS=4.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/cat/cat.c | 20 | ||||
-rw-r--r-- | bin/date/date.c | 8 | ||||
-rw-r--r-- | bin/date/netdate.c | 20 | ||||
-rw-r--r-- | bin/date/vary.c | 13 | ||||
-rw-r--r-- | bin/dd/args.c | 1 | ||||
-rw-r--r-- | bin/dd/dd.c | 5 | ||||
-rw-r--r-- | bin/dd/dd.h | 4 |
7 files changed, 35 insertions, 36 deletions
diff --git a/bin/cat/cat.c b/bin/cat/cat.c index b167fa2..c56abfb 100644 --- a/bin/cat/cat.c +++ b/bin/cat/cat.c @@ -109,7 +109,7 @@ main(int argc, char *argv[]) vflag = 1; break; default: - (void)fprintf(stderr, + fprintf(stderr, "usage: cat [-benstuv] [-] [file ...]\n"); exit(1); } @@ -187,12 +187,12 @@ cook_cat(FILE *fp) continue; } if (nflag && !bflag) { - (void)fprintf(stdout, "%6d\t", ++line); + fprintf(stdout, "%6d\t", ++line); if (ferror(stdout)) break; } } else if (nflag) { - (void)fprintf(stdout, "%6d\t", ++line); + fprintf(stdout, "%6d\t", ++line); if (ferror(stdout)) break; } @@ -240,7 +240,7 @@ raw_cat(int rfd) int off, wfd; ssize_t nr, nw; static size_t bsize; - static char *buf; + static char *buf = NULL; struct stat sbuf; wfd = fileno(stdout); @@ -268,14 +268,15 @@ udom_open(const char *path, int flags) { struct sockaddr_un sou; int fd; - int len; + unsigned int len; bzero(&sou, sizeof(sou)); /* * Construct the unix domain socket address and attempt to connect */ - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0) { + fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (fd >= 0) { sou.sun_family = AF_UNIX; snprintf(sou.sun_path, sizeof(sou.sun_path), "%s", path); len = strlen(sou.sun_path); @@ -293,10 +294,12 @@ udom_open(const char *path, int flags) if (fd >= 0) { switch(flags & O_ACCMODE) { case O_RDONLY: - shutdown(fd, SHUT_WR); + if (shutdown(fd, SHUT_WR) == -1) + perror("cat"); break; case O_WRONLY: - shutdown(fd, SHUT_RD); + if (shutdown(fd, SHUT_RD) == -1) + perror("cat"); break; default: break; @@ -306,4 +309,3 @@ udom_open(const char *path, int flags) } #endif - diff --git a/bin/date/date.c b/bin/date/date.c index 8c42f08..0cf1d1e 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -50,12 +50,13 @@ static const char rcsid[] = #include <ctype.h> #include <err.h> +#include <locale.h> +#include <libutil.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> -#include <locale.h> #include "extern.h" #include "vary.h" @@ -71,15 +72,14 @@ static void setthetime(const char *, const char *, int, int); static void badformat(void); static void usage(void); -int logwtmp(char *, char *, char *); - int main(int argc, char *argv[]) { struct timezone tz; int ch, rflag; int jflag, nflag; - char *format, buf[1024]; + const char *format; + char buf[1024]; char *endptr, *fmt; char *tmp; int set_timezone; diff --git a/bin/date/netdate.c b/bin/date/netdate.c index c8bb51a..f9866fd 100644 --- a/bin/date/netdate.c +++ b/bin/date/netdate.c @@ -73,10 +73,10 @@ netsettime(time_t tval) struct timeval tout; struct servent *sp; struct tsp msg; - struct sockaddr_in sin, dest, from; + struct sockaddr_in lsin, dest, from; fd_set ready; long waittime; - int s, length, port, timed_ack, found, err; + int s, length, port, timed_ack, found, lerr; char hostname[MAXHOSTNAMELEN]; if ((sp = getservbyname("timed", "udp")) == NULL) { @@ -94,11 +94,11 @@ netsettime(time_t tval) return (retval = 2); } - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; + memset(&lsin, 0, sizeof(lsin)); + lsin.sin_family = AF_INET; for (port = IPPORT_RESERVED - 1; port > IPPORT_RESERVED / 2; port--) { - sin.sin_port = htons((u_short)port); - if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0) + lsin.sin_port = htons((u_short)port); + if (bind(s, (struct sockaddr *)&lsin, sizeof(lsin)) >= 0) break; if (errno == EADDRINUSE) continue; @@ -142,11 +142,11 @@ loop: FD_SET(s, &ready); found = select(FD_SETSIZE, &ready, (fd_set *)0, (fd_set *)0, &tout); - length = sizeof(err); + length = sizeof(lerr); if (!getsockopt(s, - SOL_SOCKET, SO_ERROR, (char *)&err, &length) && err) { - if (err != ECONNREFUSED) - warnc(err, "send (delayed error)"); + SOL_SOCKET, SO_ERROR, (char *)&lerr, &length) && lerr) { + if (lerr != ECONNREFUSED) + warnc(lerr, "send (delayed error)"); goto bad; } diff --git a/bin/date/vary.c b/bin/date/vary.c index 7ee8a4f..2e0bb88 100644 --- a/bin/date/vary.c +++ b/bin/date/vary.c @@ -29,6 +29,7 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include <sys/cdefs.h> #include <err.h> #include <time.h> #include <string.h> @@ -37,7 +38,7 @@ static const char rcsid[] = struct trans { int val; - char *str; + const char *str; }; static struct trans trans_mon[] = { @@ -203,14 +204,14 @@ adjmon(struct tm *t, char type, int val, int istext, int mk) static int adjday(struct tm *t, char type, int val, int mk) { - int mdays; + int lmdays; switch (type) { case '+': while (val) { - mdays = daysinmonth(t); - if (val > mdays - t->tm_mday) { - val -= mdays - t->tm_mday + 1; + lmdays = daysinmonth(t); + if (val > lmdays - t->tm_mday) { + val -= lmdays - t->tm_mday + 1; t->tm_mday = 1; if (!adjmon(t, '+', 1, 0, 0)) return 0; @@ -413,7 +414,7 @@ vary_apply(const struct vary *v, struct tm *t) char type; char which; char *arg; - int len; + size_t len; int val; for (; v; v = v->next) { diff --git a/bin/dd/args.c b/bin/dd/args.c index 8e6fab6..6a4607e 100644 --- a/bin/dd/args.c +++ b/bin/dd/args.c @@ -371,6 +371,7 @@ get_num(const char *val) case 'w': mult = sizeof(int); break; + default: } if (mult != 0) { diff --git a/bin/dd/dd.c b/bin/dd/dd.c index 52d4144..cdd358e 100644 --- a/bin/dd/dd.c +++ b/bin/dd/dd.c @@ -54,7 +54,6 @@ static const char rcsid[] = #include <sys/conf.h> #include <sys/disklabel.h> #include <sys/filio.h> -#include <sys/time.h> #include <ctype.h> #include <err.h> @@ -78,8 +77,8 @@ IO in, out; /* input/output state */ STAT st; /* statistics */ void (*cfunc)(void); /* conversion function */ u_quad_t cpy_cnt; /* # of blocks to copy */ -off_t pending = 0; /* pending seek if sparse */ -u_int ddflags; /* conversion options */ +static off_t pending = 0; /* pending seek if sparse */ +u_int ddflags = 0; /* conversion options */ size_t cbsz; /* conversion block size */ quad_t files_cnt = 1; /* # of files to copy */ const u_char *ctab; /* conversion table */ diff --git a/bin/dd/dd.h b/bin/dd/dd.h index 183176b..caf161b 100644 --- a/bin/dd/dd.h +++ b/bin/dd/dd.h @@ -59,10 +59,6 @@ typedef struct { int fd; /* file descriptor */ off_t offset; /* # of blocks to skip */ - u_quad_t f_stats; /* # of full blocks processed */ - u_quad_t p_stats; /* # of partial blocks processed */ - u_quad_t s_stats; /* # of odd swab blocks */ - u_quad_t t_stats; /* # of truncations */ } IO; typedef struct { |