> This is a patch for better (I think) error handling for pccardc. > (obtained from PAO3) > > Please review.
Some of it I like, and others I don't. > @@ -138,9 +138,9 @@ > usage(msg) > char *msg; > { > - warnx("enabler: %s", msg); > + fprintf(stderr, "enabler: %s\n", msg); > fprintf(stderr, > -"usage: pccardc enabler slot driver [-m addr size] [-a iobase] [-i irq]\n"); > +"Usage: enabler slot driver [-m addr size] [-a iobase] [-i irq]\n"); The usage really is 'pccardc enabled', not 'enabler', so this should stay, or at least converted to use argv[0] to be consistent with the other changes. > Index: pccardc/pccardc.c > =================================================================== > RCS file: /home/ncvs/src/usr.sbin/pccard/pccardc/pccardc.c,v > retrieving revision 1.7 > diff -u -r1.7 pccardc.c > --- pccardc.c 1998/02/26 14:36:01 1.7 > +++ pccardc.c 1999/02/13 03:51:35 > @@ -84,10 +84,11 @@ > { > int i; > > - fprintf(stderr, "usage: pccardc <subcommand> <arg> ...\n"); > - fprintf(stderr, "subcommands:\n"); > + fprintf(stderr, "Usage:\n"); > + fprintf(stderr, "\t%s <subcommand> <arg> ...\n", argv[0]); > + fprintf(stderr, "Subcommands:\n"); > for (i = 0; subcommands[i].name; i++) > - fprintf(stderr, "\t%s\n\t\t%s\n", > + fprintf(stderr, "\t%s\t: %s\n", > subcommands[i].name, subcommands[i].help); However, I'm not sure why we are changing the output. It seems gratiutious. > -static void > -usage() > -{ > - fprintf(stderr, "usage: pccardc pccardmem [memory-address]\n"); > - exit(1); > -} > - > int > pccardmem_main(argc, argv) > int argc; > @@ -54,7 +47,8 @@ > int fd; > > if (argc > 2) > - usage(); > + errx(1, "Usage: %s pccardmem [ memory-address ]", argv[0]); > + Again, we use warn one place, and then err. Any chance of keeping it consistent in all places. Nate To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-current" in the body of the message