From: Sascha Wildner Date: Mon, 22 Dec 2008 01:22:34 +0000 (+0100) Subject: Raise WARNS to 6 and fix resulting warnings. X-Git-Tag: v2.3.0~220^2~14 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3cf8dfbcc5e851c3571a9caa420ccd50eb89a824 Raise WARNS to 6 and fix resulting warnings. --- diff --git a/libexec/pppoed/Makefile b/libexec/pppoed/Makefile index 83c26077b8..63ac31f2ec 100644 --- a/libexec/pppoed/Makefile +++ b/libexec/pppoed/Makefile @@ -3,6 +3,7 @@ PROG= pppoed SRCS= pppoed.c +WARNS?= 6 DPADD= ${LIBNETGRAPH} LDADD= -lnetgraph MAN= pppoed.8 diff --git a/libexec/pppoed/pppoed.c b/libexec/pppoed/pppoed.c index c8c18aa11b..993512df79 100644 --- a/libexec/pppoed/pppoed.c +++ b/libexec/pppoed/pppoed.c @@ -85,8 +85,8 @@ Farewell(int sig) } static int -ConfigureNode(const char *prog, const char *iface, const char *provider, - int cs, int ds, int debug, struct ngm_connect *ngc) +ConfigureNode(const char *prog __unused, const char *iface, const char *provider, + int cs, int ds __unused, int debug, struct ngm_connect *ngc) { /* * We're going to do this with the passed `ds' & `cs' descriptors: @@ -122,7 +122,8 @@ ConfigureNode(const char *prog, const char *iface, const char *provider, struct ngm_mkpeer mkp; struct ng_mesg *resp; u_char rbuf[2048]; - int f, plen; + uint32_t f; + int plen; /* * Ask for a list of hooks attached to the "ether" node. This node should @@ -251,9 +252,9 @@ ConfigureNode(const char *prog, const char *iface, const char *provider, } static void -Spawn(const char *prog, const char *acname, const char *provider, +Spawn(const char *prog __unused, const char *acname, const char *provider, const char *exec, struct ngm_connect ngc, int cs, int ds, void *request, - int sz, int debug) + size_t sz, int debug) { char msgbuf[sizeof(struct ng_mesg) + sizeof(struct ngpppoe_sts)]; struct ng_mesg *rep = (struct ng_mesg *)msgbuf; @@ -461,7 +462,7 @@ static int LoadModules(void) { const char *module[] = { "netgraph", "ng_socket", "ng_ether", "ng_pppoe" }; - int f; + size_t f; for (f = 0; f < sizeof module / sizeof *module; f++) if (modfind(module[f]) == -1 && kldload(module[f]) == -1) { diff --git a/libexec/tftpd/Makefile b/libexec/tftpd/Makefile index 941c2aca26..1f0a8f9f5c 100644 --- a/libexec/tftpd/Makefile +++ b/libexec/tftpd/Makefile @@ -4,6 +4,7 @@ PROG= tftpd SRCS= tftpd.c tftpsubs.c +WARNS?= 6 DPADD= ${LIBUTIL} LDADD= -lutil MAN= tftpd.8 diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index acc3b2d3bc..e6646ba9df 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -351,9 +351,10 @@ void tftp(struct tftphdr *tp, int size) { char *cp; - int i, first = 1, has_options = 0, ecode; + size_t i; + int first = 1, has_options = 0, ecode; struct formats *pf; - char *filename, *mode, *option, *ccp; + char *filename, *mode = NULL, *option, *ccp; char fnbuf[MAXPATHLEN]; cp = tp->th_stuff; diff --git a/usr.bin/tftp/Makefile b/usr.bin/tftp/Makefile index 09b8f05206..ea57453c9d 100644 --- a/usr.bin/tftp/Makefile +++ b/usr.bin/tftp/Makefile @@ -3,6 +3,6 @@ PROG= tftp SRCS= main.c tftp.c tftpsubs.c -WARNS?= 1 +WARNS?= 6 .include diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c index 1a354385e4..334acef72e 100644 --- a/usr.bin/tftp/main.c +++ b/usr.bin/tftp/main.c @@ -75,10 +75,10 @@ char line[200]; int margc; #define MAX_MARGV 20 char *margv[MAX_MARGV]; -char *prompt = "tftp"; +const char *prompt = "tftp"; jmp_buf toplevel; volatile int txrx_error; -void intr(); +void intr(int); void get(int, char **); void help(int, char **); @@ -87,7 +87,7 @@ void put(int, char **); void quit(int, char **); void setascii(int, char **); void setbinary(int, char **); -void setpeer0(char *, char *); +void setpeer0(char *, const char *); void setpeer(int, char **); void setrexmt(int, char **); void settimeout(int, char **); @@ -100,29 +100,29 @@ static void command(void) __dead2; static void getusage(char *); static void makeargv(void); static void putusage(char *); -static void settftpmode(char *); +static void settftpmode(const char *); #define HELPINDENT (sizeof("connect")) struct cmd { - char *name; - char *help; + const char *name; + const char *help; void (*handler)(int, char **); }; -char vhelp[] = "toggle verbose mode"; -char thelp[] = "toggle packet tracing"; -char chelp[] = "connect to remote tftp"; -char qhelp[] = "exit tftp"; -char hhelp[] = "print help information"; -char shelp[] = "send file"; -char rhelp[] = "receive file"; -char mhelp[] = "set file transfer mode"; -char sthelp[] = "show current status"; -char xhelp[] = "set per-packet retransmission timeout"; -char ihelp[] = "set total retransmission timeout"; -char ashelp[] = "set mode to netascii"; -char bnhelp[] = "set mode to octet"; +const char vhelp[] = "toggle verbose mode"; +const char thelp[] = "toggle packet tracing"; +const char chelp[] = "connect to remote tftp"; +const char qhelp[] = "exit tftp"; +const char hhelp[] = "print help information"; +const char shelp[] = "send file"; +const char rhelp[] = "receive file"; +const char mhelp[] = "set file transfer mode"; +const char sthelp[] = "show current status"; +const char xhelp[] = "set per-packet retransmission timeout"; +const char ihelp[] = "set total retransmission timeout"; +const char ashelp[] = "set mode to netascii"; +const char bnhelp[] = "set mode to octet"; struct cmd cmdtab[] = { { "connect", chelp, setpeer }, @@ -138,11 +138,11 @@ struct cmd cmdtab[] = { { "rexmt", xhelp, setrexmt }, { "timeout", ihelp, settimeout }, { "?", hhelp, help }, - { 0 } + { .name = NULL } }; -struct cmd *getcmd(); -char *tail(); +struct cmd *getcmd(char *); +char *tail(char *); int main(int argc, char **argv) @@ -163,12 +163,12 @@ main(int argc, char **argv) char hostname[MAXHOSTNAMELEN]; void -setpeer0(char *host, char *port) +setpeer0(char *host, const char *port) { struct addrinfo hints, *res0, *res; int error; struct sockaddr_storage ss; - char *cause = "unknown"; + const char *cause = "unknown"; if (connected) { close(f); @@ -251,8 +251,8 @@ setpeer(int argc, char **argv) } struct modes { - char *m_name; - char *m_mode; + const char *m_name; + const char *m_mode; } modes[] = { { "ascii", "netascii" }, { "netascii", "netascii" }, @@ -260,14 +260,14 @@ struct modes { { "image", "octet" }, { "octet", "octet" }, /* { "mail", "mail" }, */ - { 0, 0 } + { NULL, NULL } }; void modecmd(int argc, char **argv) { struct modes *p; - char *sep; + const char *sep; if (argc < 2) { printf("Using %s mode to transfer files.\n", mode); @@ -297,21 +297,21 @@ modecmd(int argc, char **argv) } void -setbinary(int argc, char **argv) +setbinary(int argc __unused, char **argv __unused) { settftpmode("octet"); } void -setascii(int argc, char **argv) +setascii(int argc __unused, char **argv __unused) { settftpmode("netascii"); } static void -settftpmode(char *newmode) +settftpmode(const char *newmode) { strcpy(mode, newmode); if (verbose) @@ -343,8 +343,6 @@ put(int argc, char **argv) } targ = argv[argc - 1]; if (strrchr(argv[argc - 1], ':')) { - char *cp; - for (n = 1; n < argc - 1; n++) if (strchr(argv[n], ':')) { putusage(argv[0]); @@ -436,7 +434,6 @@ get(int argc, char **argv) if (src == NULL) src = argv[n]; else { - char *cp; *src++ = 0; cp = argv[n]; if (cp[0] == '[' && cp[strlen(cp) - 1] == ']') { @@ -533,7 +530,7 @@ settimeout(int argc, char **argv) } void -status(int argc, char **argv) +status(int argc __unused, char **argv __unused) { if (connected) printf("Connected to %s.\n", hostname); @@ -546,9 +543,8 @@ status(int argc, char **argv) } void -intr(void) +intr(int signo __unused) { - signal(SIGALRM, SIG_IGN); alarm(0); longjmp(toplevel, -1); @@ -611,7 +607,8 @@ command(void) struct cmd * getcmd(char *name) { - char *p, *q; + const char *p; + char *q; struct cmd *c, *found; int nmatches, longest; @@ -665,7 +662,7 @@ makeargv(void) } void -quit(int argc, char **argv) +quit(int argc __unused, char **argv __unused) { exit(txrx_error); @@ -699,14 +696,14 @@ help(int argc, char **argv) } void -settrace(int argc, char **argv) +settrace(int argc __unused, char **argv __unused) { trace = !trace; printf("Packet tracing %s.\n", trace ? "on" : "off"); } void -setverbose(int argc, char **argv) +setverbose(int argc __unused, char **argv __unused) { verbose = !verbose; printf("Verbose mode %s.\n", verbose ? "on" : "off"); diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c index 8bf098ca31..5bdd826227 100644 --- a/usr.bin/tftp/tftp.c +++ b/usr.bin/tftp/tftp.c @@ -90,7 +90,7 @@ void xmitfile(int fd, char *name, char *mode) { struct tftphdr *ap; /* data and ack packets */ - struct tftphdr *r_init(), *dp; + struct tftphdr *dp; int n; volatile unsigned short block; volatile int size, convert; @@ -205,7 +205,7 @@ void recvfile(int fd, char *name, char *mode) { struct tftphdr *ap; - struct tftphdr *dp, *w_init(); + struct tftphdr *dp; int n; volatile unsigned short block; volatile int size, firsttrip; @@ -338,7 +338,7 @@ makerequest(int request, const char *name, struct tftphdr *tp, const char *mode) struct errmsg { int e_code; - char *e_msg; + const char *e_msg; } errmsgs[] = { { EUNDEF, "Undefined error code" }, { ENOTFOUND, "File not found" }, @@ -363,7 +363,6 @@ nak(int error, struct sockaddr *peer) struct errmsg *pe; struct tftphdr *tp; int length; - char *strerror(); tp = (struct tftphdr *)ackbuf; tp->th_opcode = htons((u_short)ERROR); @@ -386,7 +385,7 @@ nak(int error, struct sockaddr *peer) static void tpacket(const char *s, struct tftphdr *tp, int n) { - static char *opcodes[] = + static const char *opcodes[] = { "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR" }; char *cp, *file; u_short op = ntohs(tp->th_opcode); @@ -444,14 +443,14 @@ printstats(const char *direction, unsigned long amount) delta = ((tstop.tv_sec*10.)+(tstop.tv_usec/100000)) - ((tstart.tv_sec*10.)+(tstart.tv_usec/100000)); delta = delta/10.; /* back to seconds */ - printf("%s %d bytes in %.1f seconds", direction, amount, delta); + printf("%s %lu bytes in %.1f seconds", direction, amount, delta); if (verbose) printf(" [%.0f bits/sec]", (amount*8.)/delta); putchar('\n'); } static void -timer(int sig) +timer(int sig __unused) { timeout += rexmtval; diff --git a/usr.bin/tftp/tftpsubs.c b/usr.bin/tftp/tftpsubs.c index 432d015d90..fd31f94a21 100644 --- a/usr.bin/tftp/tftpsubs.c +++ b/usr.bin/tftp/tftpsubs.c @@ -76,7 +76,7 @@ static int current; /* index of buffer in use */ int newline = 0; /* fillbuf: in middle of newline expansion */ int prevchar = -1; /* putbuf: previous char (cr check) */ -static struct tftphdr *rw_init(); +static struct tftphdr *rw_init(int); struct tftphdr *w_init(void) { return rw_init(0); } /* write-behind */ struct tftphdr *r_init(void) { return rw_init(1); } /* read-ahead */