From owner-svn-src-all@FreeBSD.ORG Tue Jan 27 09:27:13 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE247106566C; Tue, 27 Jan 2009 09:27:13 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9257B8FC0A; Tue, 27 Jan 2009 09:27:13 +0000 (UTC) (envelope-from luigi@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n0R9RD8G079934; Tue, 27 Jan 2009 09:27:13 GMT (envelope-from luigi@svn.freebsd.org) Received: (from luigi@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n0R9RDbY079932; Tue, 27 Jan 2009 09:27:13 GMT (envelope-from luigi@svn.freebsd.org) Message-Id: <200901270927.n0R9RDbY079932@svn.freebsd.org> From: Luigi Rizzo Date: Tue, 27 Jan 2009 09:27:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r187765 - head/sbin/ipfw X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jan 2009 09:27:14 -0000 Author: luigi Date: Tue Jan 27 09:27:13 2009 New Revision: 187765 URL: http://svn.freebsd.org/changeset/base/187765 Log: put the usage() function inline, it was only 1 line and used once; slightly reformat the help() text; slightly correct the text for the 'extraneous filename' error message; Modified: head/sbin/ipfw/ipfw2.c Modified: head/sbin/ipfw/ipfw2.c ============================================================================== --- head/sbin/ipfw/ipfw2.c Tue Jan 27 09:06:25 2009 (r187764) +++ head/sbin/ipfw/ipfw2.c Tue Jan 27 09:27:13 2009 (r187765) @@ -245,8 +245,6 @@ static struct _s_x ether_types[] = { { NULL, 0 } }; -static void show_usage(void); - enum tokens { TOK_NULL=0, @@ -2726,20 +2724,12 @@ done: } static void -show_usage(void) -{ - fprintf(stderr, "usage: ipfw [options]\n" -"do \"ipfw -h\" or see ipfw manpage for details\n" -); - exit(EX_USAGE); -} - -static void help(void) { fprintf(stderr, -"ipfw syntax summary (but please do read the ipfw(8) manpage):\n" -"ipfw [-abcdefhnNqStTv] where is one of:\n" +"ipfw syntax summary (but please do read the ipfw(8) manpage):\n\n" +"\tipfw [-abcdefhnNqStTv] \n\n" +"where is one of the following:\n\n" "add [num] [set N] [prob x] RULE-BODY\n" "{pipe|queue} N config PIPE-BODY\n" "[pipe|queue] {zero|delete|show} [N{,N}]\n" @@ -6471,10 +6461,8 @@ ipfw_readfile(int ac, char *av[]) } - if (cmd == NULL && ac != optind + 1) { - fprintf(stderr, "ac %d, optind %d\n", ac, optind); - errx(EX_USAGE, "extraneous filename arguments"); - } + if (cmd == NULL && ac != optind + 1) + errx(EX_USAGE, "extraneous filename arguments %s", av[ac-1]); if ((f = fopen(filename, "r")) == NULL) err(EX_UNAVAILABLE, "fopen: %s", filename); @@ -6554,8 +6542,11 @@ main(int ac, char *av[]) if (ac > 1 && av[ac - 1][0] == '/' && access(av[ac - 1], R_OK) == 0) ipfw_readfile(ac, av); else { - if (ipfw_main(ac, av)) - show_usage(); + if (ipfw_main(ac, av)) { + errx(EX_USAGE, + "usage: ipfw [options]\n" + "do \"ipfw -h\" or \"man ipfw\" for details"); + } } return EX_OK; }