Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Sep 2019 18:39:05 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r352806 - head/tools/tools/controlelf
Message-ID:  <201909271839.x8RId5TT023198@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909271839.x8RId5TT023198>