From owner-freebsd-current Sun Feb 14 12:06:27 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA02727 for freebsd-current-outgoing; Sun, 14 Feb 1999 12:06:27 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from frmug.org (frmug-gw.frmug.org [193.56.58.252]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA02711 for ; Sun, 14 Feb 1999 12:06:22 -0800 (PST) (envelope-from charnier@xp11.frmug.org) Received: (from uucp@localhost) by frmug.org (8.9.1/frmug-2.3/nospam) with UUCP id VAA08074; Sun, 14 Feb 1999 21:05:45 +0100 (CET) (envelope-from charnier@xp11.frmug.org) Received: from xp11.frmug.org (xp11.frmug.org [127.0.0.1]) by xp11.frmug.org (8.9.2/8.9.2/xp11-uucp-1.1) with ESMTP id TAA97032; Sun, 14 Feb 1999 19:38:03 +0100 (CET) (envelope-from charnier@xp11.frmug.org) Message-Id: <199902141838.TAA97032@xp11.frmug.org> To: Jun Kuriyama cc: current@FreeBSD.ORG Subject: Re: Error handling for src/usr.sbin/pccard/pccardc/* Date: Sun, 14 Feb 1999 19:38:02 +0100 From: "Philippe Charnier" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 ...\n"); - fprintf(stderr, "subcommands:\n"); + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "\t%s ...\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