On Mon, Oct 09, 2017 at 11:56:03AM +1100, Ross L Richardson wrote: > Improved version, with thanks to anton@ > > [Should usage() be __dead?] > > Ross >
fixed, thanks. jmc > Index: pf.4 > =================================================================== > RCS file: /cvs/src/share/man/man4/pf.4,v > retrieving revision 1.88 > diff -u -p -r1.88 pf.4 > --- pf.4 29 Aug 2017 02:16:56 -0000 1.88 > +++ pf.4 9 Oct 2017 00:51:30 -0000 > @@ -1008,14 +1008,16 @@ command to show the hard limit of a memo > #include <sys/socket.h> > #include <sys/ioctl.h> > #include <sys/fcntl.h> > + > #include <netinet/in.h> > #include <net/if.h> > #include <net/pfvar.h> > + > +#include <err.h> > #include <limits.h> > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > -#include <err.h> > > static const struct { > const char *name; > @@ -1032,10 +1034,9 @@ static const struct { > void > usage(void) > { > - extern char *__progname; > int i; > > - fprintf(stderr, "usage: %s [", __progname); > + fprintf(stderr, "usage: %s [", getprogname()); > for (i = 0; pf_limits[i].name; i++) > fprintf(stderr, "%s%s", (i > 0 ? "|" : ""), pf_limits[i].name); > fprintf(stderr, "]\en"); > @@ -1053,7 +1054,7 @@ main(int argc, char *argv[]) > usage(); > > for (i = 0; pf_limits[i].name; i++) > - if (!strcmp(argv[1], pf_limits[i].name)) { > + if (strcmp(argv[1], pf_limits[i].name) == 0) { > pool_index = pf_limits[i].index; > break; > } > @@ -1067,10 +1068,10 @@ main(int argc, char *argv[]) > if (dev == -1) > err(1, "open(\e"/dev/pf\e") failed"); > > - bzero(&pl, sizeof(struct pfioc_limit)); > + memset(&pl, 0, sizeof(struct pfioc_limit)); > pl.index = pool_index; > > - if (ioctl(dev, DIOCGETLIMIT, &pl)) > + if (ioctl(dev, DIOCGETLIMIT, &pl) == -1) > err(1, "DIOCGETLIMIT"); > > printf("The %s memory pool has ", pf_limits[i].name); > @@ -1079,7 +1080,7 @@ main(int argc, char *argv[]) > else > printf("a hard limit of %u entries.\en", pl.limit); > > - return (0); > + return 0; > } > .Ed > .Sh SEE ALSO >