From owner-svn-src-head@freebsd.org Fri Sep 27 18:39:06 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 653E0129BA7; Fri, 27 Sep 2019 18:39:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46g0ty24Vfz48Zv; Fri, 27 Sep 2019 18:39:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 263E31D06A; Fri, 27 Sep 2019 18:39:06 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x8RId5m8023199; Fri, 27 Sep 2019 18:39:05 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8RId5TT023198; Fri, 27 Sep 2019 18:39:05 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201909271839.x8RId5TT023198@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 27 Sep 2019 18:39:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352806 - head/tools/tools/controlelf X-SVN-Group: head X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: head/tools/tools/controlelf X-SVN-Commit-Revision: 352806 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Sep 2019 18:39:06 -0000 Author: emaste Date: Fri Sep 27 18:39:05 2019 New Revision: 352806 URL: https://svnweb.freebsd.org/changeset/base/352806 Log: controlelf: tidy up option parsing Sponsored by: The FreeBSD Foundation Modified: head/tools/tools/controlelf/controlelf.c Modified: head/tools/tools/controlelf/controlelf.c ============================================================================== --- head/tools/tools/controlelf/controlelf.c Fri Sep 27 17:28:25 2019 (r352805) +++ head/tools/tools/controlelf/controlelf.c Fri Sep 27 18:39:05 2019 (r352806) @@ -65,7 +65,7 @@ static struct ControlFeatures featurelist[] = { { "protmax", NT_FREEBSD_FCTL_PROTMAX_DISABLE,"Disable implicit PROT_MAX" }, }; -static struct option controlelf_longopts[] = { +static struct option long_opts[] = { { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; @@ -76,38 +76,36 @@ main(int argc, char **argv) GElf_Ehdr ehdr; Elf *elf; Elf_Kind kind; - int ch, fd, listed, editfeatures, retval; + int ch, fd, editfeatures, retval; char *features; + bool lflag; - listed = 0; + lflag = 0; editfeatures = 0; retval = 0; if (elf_version(EV_CURRENT) == EV_NONE) errx(EXIT_FAILURE, "elf_version error"); - while ((ch = getopt_long(argc, argv, "hle:", controlelf_longopts, - NULL)) != -1) { + while ((ch = getopt_long(argc, argv, "hle:", long_opts, NULL)) != -1) { switch (ch) { case 'l': print_features(); - listed = 1; + lflag = true; break; case 'e': features = optarg; editfeatures = 1; break; case 'h': - usage(); - break; default: usage(); } } argc -= optind; argv += optind; - if (!argc) { - if (listed) + if (argc == 0) { + if (lflag) exit(0); else { warnx("no file(s) specified");