Date: Sun, 14 Feb 1999 19:38:02 +0100 From: "Philippe Charnier" <charnier@xp11.frmug.org> To: Jun Kuriyama <kuriyama@sky.rim.or.jp> Cc: current@FreeBSD.ORG Subject: Re: Error handling for src/usr.sbin/pccard/pccardc/* Message-ID: <199902141838.TAA97032@xp11.frmug.org>
next in thread | raw e-mail | index | archive | help
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"); Usage string use to start with "usage", not "Usage". Progname should follow. - fprintf(stderr, "usage: pccardc <subcommand> <arg> ...\n"); - fprintf(stderr, "subcommands:\n"); + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "\t%s <subcommand> <arg> ...\n", argv[0]); We do hardcode the progname, because it is known. [removing of usage()] A bad thing. - usage(); + errx(1, "Usage: %s pccardmem [ memory-address ]", argv[0]); Err(3) is wrong at displaying the usage string because it prepends the progname. + + if (argc != 4) + errx(1, "Usage: %s rdattr slot offs length", argv[0]); Errx() -> usage() + if ((buf = malloc(length)) == 0) + err(1, "%s", name); Name give no information here. And because our malloc doesn't set errno, err() which makes use of errno now prints garbage. I suggest errx(1, "malloc failed"). ------ ------ Philippe Charnier charnier@{lirmm.fr,xp11.frmug.org,FreeBSD.org} ``a PC not running FreeBSD is like a venusian with no tentacles'' ------------------------------------------------------------------------ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902141838.TAA97032>