Fix warnings inspired by lint, a commercial lint and WARNS=4.
This commit is contained in:
parent
71bea4f79d
commit
9afa09cd0e
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 @@ netsettime(time_t tval)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -371,6 +371,7 @@ get_num(const char *val)
|
||||
case 'w':
|
||||
mult = sizeof(int);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
if (mult != 0) {
|
||||
|
@ -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 */
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user