Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Oct 2008 23:10:19 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r183858 - head/usr.bin/tftp
Message-ID:  <200810132310.m9DNAJeD089204@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Mon Oct 13 23:10:19 2008
New Revision: 183858
URL: http://svn.freebsd.org/changeset/base/183858

Log:
  ANSIfy, plus constify interfaces where possible.

Modified:
  head/usr.bin/tftp/extern.h
  head/usr.bin/tftp/main.c
  head/usr.bin/tftp/tftp.c
  head/usr.bin/tftp/tftpsubs.c

Modified: head/usr.bin/tftp/extern.h
==============================================================================
--- head/usr.bin/tftp/extern.h	Mon Oct 13 22:50:38 2008	(r183857)
+++ head/usr.bin/tftp/extern.h	Mon Oct 13 23:10:19 2008	(r183858)
@@ -34,5 +34,5 @@
  * $FreeBSD$
  */
 
-void	recvfile(int, char *, char *);
-void	xmitfile(int, char *, char *);
+void	recvfile(int, const char *, const char *);
+void	xmitfile(int, const char *, const char *);

Modified: head/usr.bin/tftp/main.c
==============================================================================
--- head/usr.bin/tftp/main.c	Mon Oct 13 22:50:38 2008	(r183857)
+++ head/usr.bin/tftp/main.c	Mon Oct 13 23:10:19 2008	(r183858)
@@ -109,9 +109,9 @@ void	status(int, char **);
 static void command(void) __dead2;
 static const char *command_prompt(void);
 
-static void getusage(char *);
+static void getusage(const char *);
 static void makeargv(void);
-static void putusage(char *);
+static void putusage(const char *);
 static void settftpmode(const char *);
 
 char	*tail(char *);
@@ -157,9 +157,7 @@ struct cmd cmdtab[] = {
 };
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
 	f = -1;
 	strcpy(mode, "netascii");
@@ -177,9 +175,7 @@ main(argc, argv)
 char    hostname[MAXHOSTNAMELEN];
 
 void
-setpeer0(host, port)
-	char *host;
-	const char *port;
+setpeer0(char *host, const char *port)
 {
 	struct addrinfo hints, *res0, *res;
 	int error;
@@ -244,9 +240,7 @@ setpeer0(host, port)
 }
 
 void
-setpeer(argc, argv)
-	int argc;
-	char *argv[];
+setpeer(int argc, char *argv[])
 {
 
 	if (argc < 2) {
@@ -281,9 +275,7 @@ struct	modes {
 };
 
 void
-modecmd(argc, argv)
-	int argc;
-	char *argv[];
+modecmd(int argc, char *argv[])
 {
 	struct modes *p;
 	const char *sep;
@@ -316,26 +308,21 @@ modecmd(argc, argv)
 }
 
 void
-setbinary(argc, argv)
-	int argc __unused;
-	char *argv[] __unused;
+setbinary(int argc __unused, char *argv[] __unused)
 {
 
 	settftpmode("octet");
 }
 
 void
-setascii(argc, argv)
-	int argc __unused;
-	char *argv[] __unused;
+setascii(int argc __unused, char *argv[] __unused)
 {
 
 	settftpmode("netascii");
 }
 
 static void
-settftpmode(newmode)
-	const char *newmode;
+settftpmode(const char *newmode)
 {
 	strcpy(mode, newmode);
 	if (verbose)
@@ -347,9 +334,7 @@ settftpmode(newmode)
  * Send file(s).
  */
 void
-put(argc, argv)
-	int argc;
-	char *argv[];
+put(int argc, char *argv[])
 {
 	int fd;
 	int n;
@@ -421,8 +406,7 @@ put(argc, argv)
 }
 
 static void
-putusage(s)
-	char *s;
+putusage(const char *s)
 {
 	printf("usage: %s file [[host:]remotename]\n", s);
 	printf("       %s file1 file2 ... fileN [[host:]remote-directory]\n", s);
@@ -432,9 +416,7 @@ putusage(s)
  * Receive file(s).
  */
 void
-get(argc, argv)
-	int argc;
-	char *argv[];
+get(int argc, char *argv[])
 {
 	int fd;
 	int n;
@@ -504,8 +486,7 @@ get(argc, argv)
 }
 
 static void
-getusage(s)
-	char *s;
+getusage(const char *s)
 {
 	printf("usage: %s [host:]file [localname]\n", s);
 	printf("       %s [host1:]file1 [host2:]file2 ... [hostN:]fileN\n", s);
@@ -514,9 +495,7 @@ getusage(s)
 int	rexmtval = TIMEOUT;
 
 void
-setrexmt(argc, argv)
-	int argc;
-	char *argv[];
+setrexmt(int argc, char *argv[])
 {
 	int t;
 
@@ -542,9 +521,7 @@ setrexmt(argc, argv)
 int	maxtimeout = 5 * TIMEOUT;
 
 void
-settimeout(argc, argv)
-	int argc;
-	char *argv[];
+settimeout(int argc, char *argv[])
 {
 	int t;
 
@@ -568,9 +545,7 @@ settimeout(argc, argv)
 }
 
 void
-status(argc, argv)
-	int argc __unused;
-	char *argv[] __unused;
+status(int argc __unused, char *argv[] __unused)
 {
 	if (connected)
 		printf("Connected to %s.\n", hostname);
@@ -583,8 +558,7 @@ status(argc, argv)
 }
 
 void
-intr(dummy)
-	int dummy __unused;
+intr(int dummy __unused)
 {
 
 	signal(SIGALRM, SIG_IGN);
@@ -593,8 +567,7 @@ intr(dummy)
 }
 
 char *
-tail(filename)
-	char *filename;
+tail(char *filename)
 {
 	char *s;
 
@@ -610,7 +583,7 @@ tail(filename)
 }
 
 static const char *
-command_prompt()
+command_prompt(void)
 {
 
 	return ("tftp> ");
@@ -620,7 +593,7 @@ command_prompt()
  * Command parser.
  */
 static void
-command()
+command(void)
 {
 	HistEvent he;
 	struct cmd *c;
@@ -679,8 +652,7 @@ command()
 }
 
 struct cmd *
-getcmd(name)
-	char *name;
+getcmd(char *name)
 {
 	const char *p, *q;
 	struct cmd *c, *found;
@@ -711,7 +683,7 @@ getcmd(name)
  * Slice a string up into argc/argv.
  */
 static void
-makeargv()
+makeargv(void)
 {
 	char *cp;
 	char **argp = margv;
@@ -736,9 +708,7 @@ makeargv()
 }
 
 void
-quit(argc, argv)
-	int argc __unused;
-	char *argv[] __unused;
+quit(int argc __unused, char *argv[] __unused)
 {
 	exit(txrx_error);
 }
@@ -747,9 +717,7 @@ quit(argc, argv)
  * Help command.
  */
 void
-help(argc, argv)
-	int argc;
-	char *argv[];
+help(int argc, char *argv[])
 {
 	struct cmd *c;
 
@@ -773,18 +741,14 @@ help(argc, argv)
 }
 
 void
-settrace(argc, argv)
-	int argc __unused;
-	char **argv __unused;
+settrace(int argc __unused, char **argv __unused)
 {
 	trace = !trace;
 	printf("Packet tracing %s.\n", trace ? "on" : "off");
 }
 
 void
-setverbose(argc, argv)
-	int argc __unused;
-	char **argv __unused;
+setverbose(int argc __unused, char **argv __unused)
 {
 	verbose = !verbose;
 	printf("Verbose mode %s.\n", verbose ? "on" : "off");

Modified: head/usr.bin/tftp/tftp.c
==============================================================================
--- head/usr.bin/tftp/tftp.c	Mon Oct 13 22:50:38 2008	(r183857)
+++ head/usr.bin/tftp/tftp.c	Mon Oct 13 23:10:19 2008	(r183858)
@@ -80,23 +80,20 @@ int	timeout;
 jmp_buf	toplevel;
 jmp_buf	timeoutbuf;
 
-static void nak(int, struct sockaddr *);
+static void nak(int, const struct sockaddr *);
 static int makerequest(int, const char *, struct tftphdr *, const char *);
 static void printstats(const char *, unsigned long);
 static void startclock(void);
 static void stopclock(void);
 static void timer(int);
 static void tpacket(const char *, struct tftphdr *, int);
-static int cmpport(struct sockaddr *, struct sockaddr *);
+static int cmpport(const struct sockaddr *, const struct sockaddr *);
 
 /*
  * Send the requested file.
  */
 void
-xmitfile(fd, name, mode)
-	int fd;
-	char *name;
-	char *mode;
+xmitfile(int fd, const char *name, const char *mode)
 {
 	struct tftphdr *ap;	   /* data and ack packets */
 	struct tftphdr *dp;
@@ -212,10 +209,7 @@ abort:
  * Receive a file.
  */
 void
-recvfile(fd, name, mode)
-	int fd;
-	char *name;
-	char *mode;
+recvfile(int fd, const char *name, const char *mode)
 {
 	struct tftphdr *ap;
 	struct tftphdr *dp;
@@ -335,11 +329,7 @@ abort:						/* ok to ack, since user */
 }
 
 static int
-makerequest(request, name, tp, mode)
-	int request;
-	const char *name;
-	struct tftphdr *tp;
-	const char *mode;
+makerequest(int request, const char *name, struct tftphdr *tp, const char *mode)
 {
 	char *cp;
 
@@ -376,9 +366,7 @@ struct errmsg {
  * offset by 100.
  */
 static void
-nak(error, peer)
-	int error;
-	struct sockaddr *peer;
+nak(int error, const struct sockaddr *peer)
 {
 	struct errmsg *pe;
 	struct tftphdr *tp;
@@ -403,10 +391,7 @@ nak(error, peer)
 }
 
 static void
-tpacket(s, tp, n)
-	const char *s;
-	struct tftphdr *tp;
-	int n;
+tpacket(const char *s, struct tftphdr *tp, int n)
 {
 	static const char *opcodes[] =
 	   { "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR" };
@@ -445,23 +430,21 @@ struct timeval tstart;
 struct timeval tstop;
 
 static void
-startclock()
+startclock(void)
 {
 
 	(void)gettimeofday(&tstart, NULL);
 }
 
 static void
-stopclock()
+stopclock(void)
 {
 
 	(void)gettimeofday(&tstop, NULL);
 }
 
 static void
-printstats(direction, amount)
-	const char *direction;
-	unsigned long amount;
+printstats(const char *direction, unsigned long amount)
 {
 	double delta;
 			/* compute delta in 1/10's second units */
@@ -475,8 +458,7 @@ printstats(direction, amount)
 }
 
 static void
-timer(sig)
-	int sig __unused;
+timer(int sig __unused)
 {
 
 	timeout += rexmtval;
@@ -489,9 +471,7 @@ timer(sig)
 }
 
 static int
-cmpport(sa, sb)
-	struct sockaddr *sa;
-	struct sockaddr *sb;
+cmpport(const struct sockaddr *sa, const struct sockaddr *sb)
 {
 	char a[NI_MAXSERV], b[NI_MAXSERV];
 

Modified: head/usr.bin/tftp/tftpsubs.c
==============================================================================
--- head/usr.bin/tftp/tftpsubs.c	Mon Oct 13 22:50:38 2008	(r183857)
+++ head/usr.bin/tftp/tftpsubs.c	Mon Oct 13 23:10:19 2008	(r183858)
@@ -85,9 +85,8 @@ 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 */
 
-static struct tftphdr *
-rw_init(x)			/* init for either read-ahead or write-behind */
-	int x;			/* zero for write-behind, one for read-head */
+static struct tftphdr *		/* init for either read-ahead or write-behind */
+rw_init(int x)			/* zero for write-behind, one for read-head */
 {
 	newline = 0;		/* init crlf flag */
 	prevchar = -1;
@@ -103,10 +102,9 @@ rw_init(x)			/* init for either read-ahe
    Free it and return next buffer filled with data.
  */
 int
-readit(file, dpp, convert)
-	FILE *file;                     /* file opened for read */
-	struct tftphdr **dpp;
-	int convert;                    /* if true, convert to ascii */
+readit(FILE *file,			/* file opened for read */
+	struct tftphdr **dpp,
+	int convert)			/* if true, convert to ascii */
 {
 	struct bf *b;
 
@@ -126,9 +124,8 @@ readit(file, dpp, convert)
  * conversions are  lf -> cr,lf  and cr -> cr, nul
  */
 void
-read_ahead(file, convert)
-	FILE *file;                     /* file opened for read */
-	int convert;                    /* if true, convert to ascii */
+read_ahead(FILE *file,			/* file opened for read */
+	int convert)			/* if true, convert to ascii */
 {
 	register int i;
 	register char *p;
@@ -175,10 +172,7 @@ read_ahead(file, convert)
    available.
  */
 int
-writeit(file, dpp, ct, convert)
-	FILE *file;
-	struct tftphdr **dpp;
-	int ct, convert;
+writeit(FILE *file, struct tftphdr **dpp, int ct, int convert)
 {
 	bfs[current].counter = ct;      /* set size of data to write */
 	current = !current;             /* switch to other buffer */
@@ -196,9 +190,7 @@ writeit(file, dpp, ct, convert)
  * CR followed by anything else.  In this case we leave it alone.
  */
 int
-write_behind(file, convert)
-	FILE *file;
-	int convert;
+write_behind(FILE *file, int convert)
 {
 	char *buf;
 	int count;
@@ -255,8 +247,7 @@ skipit:
  */
 
 int
-synchnet(f)
-	int	f;		/* socket to flush */
+synchnet(int f)			/* socket to flush */
 {
 	int i, j = 0;
 	char rbuf[PKTSIZE];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810132310.m9DNAJeD089204>