Date: Mon, 25 Jun 2001 11:30:43 -0400 (EDT) From: Mike Barcroft <mike@q9media.com> To: Dima Dorfman <dima@unixfreak.org> Cc: audit@FreeBSD.ORG Subject: Re: src/usr.sbin/spray patch Message-ID: <200106251530.f5PFUhS92501@coffee.q9media.com>
next in thread | raw e-mail | index | archive | help
Dima Dorfman <dima@unixfreak.org> writes: > If you're going to ANSIify these, you might as well ANSIify the rest > (i.e., main). As Warner (imp@) said to me once, "The one thing worse > than old K&R code in the tree is broken K&R code in the tree." Oops, missed main(). Thanks for spotting that. Updated patch at the bottom of this e-mail and also available at: http://testbed.q9media.net/freebsd/spray.20010626.patch I've also cleaned up the way 'count' is handled. Best regards, Mike Barcroft ----------------------------------------------------------------------- spray.20010626.patch o Add missing header o Make some ints unsigned to avoid compiler warnings. o Since the prototypes aren't K&R compatible anyway, convert them to ANSI C. o Set WARNS?=2 Index: spray/Makefile =================================================================== RCS file: /home/ncvs/src/usr.sbin/spray/Makefile,v retrieving revision 1.7 diff -u -r1.7 Makefile --- spray/Makefile 2001/03/26 14:41:59 1.7 +++ spray/Makefile 2001/06/25 14:50:45 @@ -1,6 +1,7 @@ # $FreeBSD: src/usr.sbin/spray/Makefile,v 1.7 2001/03/26 14:41:59 ru Exp $ PROG= spray +WARNS?= 2 MAN= spray.8 DPADD= ${LIBRPCSVC} LDADD= -lrpcsvc Index: spray/spray.c =================================================================== RCS file: /home/ncvs/src/usr.sbin/spray/spray.c,v retrieving revision 1.6 diff -u -r1.6 spray.c --- spray/spray.c 2000/05/28 15:05:15 1.6 +++ spray/spray.c 2001/06/25 14:50:46 @@ -33,6 +33,7 @@ "$FreeBSD: src/usr.sbin/spray/spray.c,v 1.6 2000/05/28 15:05:15 charnier Exp $"; #endif /* not lint */ +#include <err.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -44,8 +45,8 @@ #define SPRAYOVERHEAD 86 #endif -static void usage (); -void print_xferstats (); +static void usage(void); +static void print_xferstats(unsigned int, int, double); /* spray buffer */ char spray_buffer[SPRAYMAX]; @@ -56,16 +57,14 @@ struct timeval TIMEOUT = { 25, 0 }; int -main(argc, argv) - int argc; - char **argv; +main(int argc, char *argv[]) { spraycumul host_stats; sprayarr host_array; CLIENT *cl; int c; - int i; - int count = 0; + u_int i; + u_int count = 0; int delay = 0; int length = 0; double xmit_time; /* time to receive data */ @@ -143,7 +142,7 @@ /* Spray server with packets */ - printf ("sending %d packets of lnth %d to %s ...", count, length, *argv); + printf ("sending %u packets of lnth %d to %s ...", count, length, *argv); fflush (stdout); for (i = 0; i < count; i++) { @@ -186,11 +185,8 @@ } -void -print_xferstats(packets, packetlen, xfertime) - int packets; - int packetlen; - double xfertime; +static void +print_xferstats(u_int packets, int packetlen, double xfertime) { int datalen; double pps; /* packets per second */ @@ -212,7 +208,7 @@ static void -usage () +usage(void) { fprintf(stderr, "usage: spray [-c count] [-l length] [-d delay] host\n"); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106251530.f5PFUhS92501>