diff options
author | joerg <joerg@pkgsrc.org> | 2013-10-04 18:36:16 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2013-10-04 18:36:16 +0000 |
commit | 11cb138c4c966e497cc34291ac5b80562a792a66 (patch) | |
tree | cf21a4c13ce60bd56e3cfee2fe5f93b8d0d5f8ed | |
parent | c93e6118aff94604ecfb6d2cdf1054d558137fb8 (diff) | |
download | pkgsrc-11cb138c4c966e497cc34291ac5b80562a792a66.tar.gz |
Use modern C features like variadic functions.
-rw-r--r-- | misc/team/distinfo | 4 | ||||
-rw-r--r-- | misc/team/patches/patch-ab | 175 |
2 files changed, 135 insertions, 44 deletions
diff --git a/misc/team/distinfo b/misc/team/distinfo index 175498c4e1b..6243bef8cbd 100644 --- a/misc/team/distinfo +++ b/misc/team/distinfo @@ -1,7 +1,7 @@ -$NetBSD: distinfo,v 1.7 2011/08/13 09:09:00 apb Exp $ +$NetBSD: distinfo,v 1.8 2013/10/04 18:36:16 joerg Exp $ SHA1 (team-3.1.tar.gz) = e294d0f8e229c0526126e3f99717e9b0096cee1f RMD160 (team-3.1.tar.gz) = 07c9b540944a591b92bcf5021aa044e7c6ddd484 Size (team-3.1.tar.gz) = 10932 bytes SHA1 (patch-aa) = 044b6f7e2a1f4d24db0a813a9a0c46a05ca15f69 -SHA1 (patch-ab) = 80eccb8438771eb614b2b1097e0e7ef9f9b5698f +SHA1 (patch-ab) = f4ab5b1d2caff6e7786ac8d763edceb06840aace diff --git a/misc/team/patches/patch-ab b/misc/team/patches/patch-ab index dfd82da7fe8..4df28e389f8 100644 --- a/misc/team/patches/patch-ab +++ b/misc/team/patches/patch-ab @@ -1,4 +1,4 @@ -$NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ +$NetBSD: patch-ab,v 1.7 2013/10/04 18:36:16 joerg Exp $ --- team.c.orig 1995-07-01 15:33:24.000000000 +0000 +++ team.c @@ -13,7 +13,11 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ #define TeamLBUFSZ (64) /* Low buffer size */ #define TeamDBUFSZ (60*512) /* Default buffer size */ -@@ -80,15 +80,30 @@ static char Notice[] = +@@ -77,18 +77,34 @@ static char Notice[] = + out for locking and variable number of arguments. + */ + ++#include <stdarg.h> #include <errno.h> #include <signal.h> #include <stdio.h> @@ -44,7 +48,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ #if (PCG) # include "Extend.h" # include "Here.h" -@@ -99,6 +114,7 @@ static char Notice[] = +@@ -99,6 +115,7 @@ static char Notice[] = # define fast register # define global /* extern */ # define local static @@ -52,15 +56,36 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ # define when break; case # define otherwise break; default # define mode(which,name) typedef which name name; which name -@@ -137,6 +153,7 @@ static char Notice[] = +@@ -137,10 +154,12 @@ static char Notice[] = #endif /*VARARGS1*/ -+int - mesg(a,b,c,d,e,f,g,h,i) - char *a; - int b,c,d,e,f,g,h,i; -@@ -160,17 +177,15 @@ mesg(a,b,c,d,e,f,g,h,i) +-mesg(a,b,c,d,e,f,g,h,i) +- char *a; +- int b,c,d,e,f,g,h,i; ++__printflike(1, 2) ++void ++mesg(const char *fmt, ...) + { ++ va_list ap; ++ va_start(ap, fmt); + # if (defined F_SETLKW) + struct flock l; + l.l_whence = 0; l.l_start = 0L; l.l_len = 0L; +@@ -149,28 +168,27 @@ mesg(a,b,c,d,e,f,g,h,i) + # if (defined LOCK_EX) + flock(fileno(stderr),LOCK_EX); + # endif +- fprintf(stderr,a,b,c,d,e,f,g,h,i); ++ vfprintf(stderr, fmt, ap); + # if (defined LOCK_EX) + flock(fileno(stderr),LOCK_UN); + # endif + # if (defined F_SETLKW) + l.l_type = F_UNLCK; fcntl(fileno(stderr),F_SETLKW,&l); + # endif ++ va_end(ap); + } local bool verbose = false; local bool report = true; @@ -80,7 +105,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ extern char *optarg; extern int optind; -@@ -190,7 +205,7 @@ mode(struct,Fd) +@@ -190,7 +208,7 @@ mode(struct,Fd) { int fd; short status; @@ -89,7 +114,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ }; local Fd FdIn,FdOut; -@@ -199,7 +214,7 @@ local bool FdOpen on((fd,ffd,size)) is +@@ -199,7 +217,7 @@ local bool FdOpen on((fd,ffd,size)) is ( fast Fd *fd _ int ffd @@ -98,7 +123,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { fd->status = (ffd >= 0) ? FdOPEN : FdCLOSED; -@@ -252,12 +267,12 @@ _ fast Fd *from +@@ -252,12 +270,12 @@ _ fast Fd *from to->fd = from->fd; } @@ -114,7 +139,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { int tty; -@@ -286,16 +301,21 @@ _ long unsigned space +@@ -286,16 +304,21 @@ _ long unsigned space do { #if (defined i386 || defined sun) @@ -138,7 +163,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ read(tty,reply,sizeof reply); } -@@ -320,7 +340,7 @@ _ long unsigned space +@@ -320,7 +343,7 @@ _ long unsigned space local unsigned FdCanDo on((remaining,available)) is ( fast address remaining @@ -147,7 +172,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { return (remaining < available) -@@ -332,16 +352,16 @@ local address FdRead on((fd,buffer,todo +@@ -332,16 +355,16 @@ local address FdRead on((fd,buffer,todo fast Fd *fd _ pointer buffer _ fast address todo @@ -167,7 +192,16 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ when FdERROR: return -1; when FdCLOSED: return -1; -@@ -373,16 +393,16 @@ local address FdWrite on((fd,buffer,tod +@@ -365,7 +388,7 @@ _ long unsigned done + + return (justDone == 0) ? bytesRead : justDone; + } +- /*NOTREACHED*/ ++ return -1; + } + + local address FdWrite on((fd,buffer,todo,done)) is +@@ -373,16 +396,16 @@ local address FdWrite on((fd,buffer,tod fast Fd *fd _ pointer buffer _ fast address todo @@ -187,7 +221,16 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ when FdERROR: return -1; when FdCLOSED: return -1; -@@ -453,7 +473,7 @@ mode(struct,StreamMsg) +@@ -406,7 +429,7 @@ _ long unsigned done + + return (justDone == 0) ? bytesWritten : justDone; + } +- /*NOTREACHED*/ ++ return -1; + } + + /* +@@ -453,7 +476,7 @@ mode(struct,StreamMsg) { Token token; short status; @@ -196,7 +239,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ }; local bool StreamSend on((fd,token,status,done)) is -@@ -461,7 +481,7 @@ local bool StreamSend on((fd,token,stat +@@ -461,7 +484,7 @@ local bool StreamSend on((fd,token,stat fast Fd *fd _ Token token _ short status @@ -205,7 +248,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { fast int n; -@@ -483,7 +503,7 @@ local bool StreamReceive on((fd,tokenp, +@@ -483,7 +506,7 @@ local bool StreamReceive on((fd,tokenp, fast Fd *fd _ Token *tokenp _ short *statusp @@ -214,16 +257,16 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { fast int n; -@@ -536,7 +556,7 @@ _ Fd *downstream +@@ -536,7 +559,7 @@ _ Fd *downstream #define GuyRECEIVE(guy,tokenp,statusp,donep) \ StreamReceive(&guy->upStream,tokenp,statusp,donep) -local bool GuyStop of((Guy *,char *,long unsigned)); -+local bool GuyStop of((Guy *,char *,unsigned long long)); ++local void GuyStop of((Guy *,char *,unsigned long long)); local bool GuyStart on((guy,bufsize)) is ( -@@ -547,7 +567,7 @@ _ address bufsize +@@ -547,7 +570,7 @@ _ address bufsize fast char *buffer; Token token; short status; @@ -232,7 +275,17 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ bool received; static int bytesRead,bytesWritten; -@@ -564,7 +584,7 @@ _ address bufsize +@@ -556,15 +579,15 @@ _ address bufsize + buffer = (pointer) malloc((unsigned) bufsize); + if (buffer == nil(pointer)) + { +- mesg("team: guy %d cannot allocate %u bytes\n", +- guy->pid,bufsize); ++ mesg("team: guy %d cannot allocate %llu bytes\n", ++ guy->pid, (unsigned long long)bufsize); + return false; + } + while ((received = GuyRECEIVE(guy,&token,&status,&done)) && token != TokenSTOP) switch (token) { @@ -241,7 +294,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ FdIn.status = status; Mesg(("GuyStart reading %d chars\n",bufsize)); -@@ -577,7 +597,7 @@ _ address bufsize +@@ -577,7 +600,7 @@ _ address bufsize done += bytesRead; if (verbose) @@ -250,7 +303,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ if (!GuySEND(guy,TokenREAD,FdIn.status,done)) GuyStop(guy,"guy cannot send READ",done); -@@ -595,7 +615,7 @@ _ address bufsize +@@ -595,7 +618,7 @@ _ address bufsize done += bytesWritten; if (verbose) @@ -259,7 +312,17 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ if (!GuySEND(guy,TokenWRITE,FdOut.status,done)) GuyStop(guy,"guy cannot send WRITE",done); -@@ -619,7 +639,7 @@ local bool GuyStop on((guy,errormsg,don +@@ -611,15 +634,14 @@ _ address bufsize + + GuyStop(guy,(received) ? nil(char *) : "error on upstream receive",0L); + /*NOTREACHED*/ +- +- /*return true;*/ ++ exit(0); + } + +-local bool GuyStop on((guy,errormsg,done)) is ++local void GuyStop on((guy,errormsg,done)) is ( fast Guy *guy _ char *errormsg @@ -268,18 +331,18 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { Mesg(("GuyStop guy %#o\n",guy)); -@@ -627,8 +647,8 @@ _ long unsigned done +@@ -627,8 +649,8 @@ _ long unsigned done if (done) { if (report) - mesg("%lu kilobytes, %lu seconds\r\n", - done>>10,(long unsigned) (time((time_t *) 0)-origin)); -+ mesg("%qu kilobytes, %lu seconds\r\n", ++ mesg("%qu kilobytes, %llu seconds\r\n", + done>>10,(unsigned long long) (time((time_t *) 0)-origin)); else if (verbose) mesg("\n"); } -@@ -637,7 +657,7 @@ _ long unsigned done +@@ -637,7 +659,7 @@ _ long unsigned done { mesg("team: guy pid %u: %s\n",guy->pid,errormsg); call GuySEND(guy,TokenABORT,FdERROR,0L); @@ -288,7 +351,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ /*NOTREACHED*/ } -@@ -697,8 +717,8 @@ local bool TeamStart on((team,bufsize,i +@@ -697,8 +719,8 @@ local bool TeamStart on((team,bufsize,i ( fast Team *team _ address bufsize @@ -299,7 +362,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ ) { /* -@@ -797,6 +817,9 @@ _ long unsigned osize +@@ -797,6 +819,9 @@ _ long unsigned osize { pid = getpid(); @@ -309,7 +372,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ if (!FdClose(&last_downstream)) perror("cannot close inherited first link"); -@@ -816,13 +839,13 @@ _ long unsigned osize +@@ -816,13 +841,13 @@ _ long unsigned osize } } @@ -325,7 +388,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ { perror("cannot send first WRITE token"); return false; -@@ -864,6 +887,14 @@ local bool TeamWait on((team)) is +@@ -864,6 +889,14 @@ local bool TeamWait on((team)) is --team->active; @@ -340,18 +403,34 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ if (status != 0 && team->active != 0) return false; } -@@ -914,8 +945,8 @@ local void usage of((noparms)) +@@ -900,8 +933,7 @@ local bool TeamClose on((team)) is + fast Team *team + ) + { +- for (team->size; team->size != 0; --team->size) +- continue; ++ team->size = 0; + + free(team->guys); + +@@ -914,32 +946,32 @@ local void usage of((noparms)) syntax: team [-[vr]] [-iI[bkm] [-oO[bkm] [N[bkm] [P]]\n\ copies standard input to output\n\ -v gives ongoing report, -r final report\n\ - I is input volume size (default %lum)\n\ - O is output volume size (default %lum)\n\ +- N is buffer size (default %luk)\n\ + I is input volume size (default %qum)\n\ + O is output volume size (default %qum)\n\ - N is buffer size (default %luk)\n\ ++ N is buffer size (default %lluk)\n\ P is number of processes (default %u)\n\ (postfix b means *512, k means *1KB, m means *1MB)\n\ -@@ -927,19 +958,19 @@ syntax: team [-[vr]] [-iI[bkm] [-oO[bkm] + ", + TeamHVOLSZ>>20,TeamHVOLSZ>>20, +- TeamDBUFSZ>>10,TeamDTEAMSZ); ++ (unsigned long long)(TeamDBUFSZ>>10),TeamDTEAMSZ); + + exit(1); /*NOTREACHED*/ } @@ -365,7 +444,8 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ + fast unsigned long long l; for ( - s, l = 0L; +- s, l = 0L; ++ l = 0L; *s >= '0' && *s <= '9'; s++ ) @@ -374,7 +454,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ if (*s == 'b') l *= (1L<<9); if (*s == 'k') l *= (1L<<10); -@@ -958,8 +989,8 @@ _ char *(argv[]) +@@ -958,8 +990,8 @@ _ char *(argv[]) short unsigned teamsize; address bufsize; @@ -385,7 +465,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ int opt; teamsize = TeamDTEAMSZ; -@@ -971,11 +1002,11 @@ _ char *(argv[]) +@@ -971,11 +1003,11 @@ _ char *(argv[]) while ((opt = getopt(argc,argv,"vri:o:")) != -1) switch (opt) { @@ -399,7 +479,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ usage(); } -@@ -983,7 +1014,7 @@ _ char *(argv[]) +@@ -983,7 +1015,7 @@ _ char *(argv[]) osize = atos(optarg); if (osize < TeamLVOLSZ || osize > TeamHVOLSZ) { @@ -408,7 +488,18 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ usage(); } -@@ -1032,6 +1063,11 @@ _ char *(argv[]) +@@ -1004,8 +1036,8 @@ _ char *(argv[]) + bufsize = (address) atos(argv[0]); + if (bufsize < TeamLBUFSZ || bufsize > TeamHBUFSZ) + { +- fprintf(stderr,"team: invalid block size %u\n", +- bufsize); ++ fprintf(stderr,"team: invalid block size %llu\n", ++ (unsigned long long)bufsize); + usage(); + } + --argc, argv++; +@@ -1032,6 +1064,11 @@ _ char *(argv[]) origin = time((time_t *) 0); @@ -420,7 +511,7 @@ $NetBSD: patch-ab,v 1.6 2011/08/13 09:09:00 apb Exp $ if (!TeamStart(&team,bufsize,isize,osize)) { mesg("team: cannot start the team\n"); -@@ -1055,5 +1091,11 @@ _ char *(argv[]) +@@ -1055,5 +1092,11 @@ _ char *(argv[]) return 1; } |