From d72ba183ff2d28704755e3044193d465d29c6585 Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Sun, 18 Nov 2018 12:03:12 +0000 Subject: [PATCH] brandelf: fix style nits No functional change intended. Reviewed by: emaste, markj Differential Revision: https://reviews.freebsd.org/D17966 --- usr.bin/brandelf/brandelf.c | 51 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/usr.bin/brandelf/brandelf.c b/usr.bin/brandelf/brandelf.c index e30f45e4aceb..2dc84796c836 100644 --- a/usr.bin/brandelf/brandelf.c +++ b/usr.bin/brandelf/brandelf.c @@ -32,11 +32,13 @@ #include __FBSDID("$FreeBSD$"); -#include +#include #include #include + #include #include +#include #include #include #include @@ -64,16 +66,21 @@ main(int argc, char **argv) { const char *strtype = "FreeBSD"; - int type = ELFOSABI_FREEBSD; - int retval = 0; - int ch, change = 0, force = 0, listed = 0; + int ch, retval, type; + bool change, force, listed; + + type = ELFOSABI_FREEBSD; + retval = 0; + change = false; + force = false; + listed = false; while ((ch = getopt(argc, argv, "f:lt:v")) != -1) switch (ch) { case 'f': if (change) errx(1, "f option incompatible with t option"); - force = 1; + force = true; type = atoi(optarg); if (errno == ERANGE || type < 0 || type > 255) { warnx("invalid argument to option f: %s", @@ -83,7 +90,7 @@ main(int argc, char **argv) break; case 'l': printelftypes(); - listed = 1; + listed = true; break; case 'v': /* does nothing */ @@ -91,7 +98,7 @@ main(int argc, char **argv) case 't': if (force) errx(1, "t option incompatible with f option"); - change = 1; + change = true; strtype = optarg; break; default: @@ -99,7 +106,7 @@ main(int argc, char **argv) } argc -= optind; argv += optind; - if (!argc) { + if (argc == 0) { if (listed) exit(0); else { @@ -114,7 +121,7 @@ main(int argc, char **argv) usage(); } - while (argc) { + while (argc != 0) { int fd; char buffer[EI_NIDENT]; @@ -160,7 +167,7 @@ main(int argc, char **argv) argv++; } - return retval; + return (retval); } static void @@ -176,12 +183,10 @@ iselftype(int etype) { size_t elfwalk; - for (elfwalk = 0; - elfwalk < sizeof(elftypes)/sizeof(elftypes[0]); - elfwalk++) + for (elfwalk = 0; elfwalk < nitems(elftypes); elfwalk++) if (etype == elftypes[elfwalk].value) - return elftypes[elfwalk].str; - return 0; + return (elftypes[elfwalk].str); + return (0); } static int @@ -189,12 +194,10 @@ elftype(const char *elfstrtype) { size_t elfwalk; - for (elfwalk = 0; - elfwalk < sizeof(elftypes)/sizeof(elftypes[0]); - elfwalk++) + for (elfwalk = 0; elfwalk < nitems(elftypes); elfwalk++) if (strcasecmp(elfstrtype, elftypes[elfwalk].str) == 0) - return elftypes[elfwalk].value; - return -1; + return (elftypes[elfwalk].value); + return (-1); } static void @@ -203,10 +206,8 @@ printelftypes(void) size_t elfwalk; fprintf(stderr, "known ELF types are: "); - for (elfwalk = 0; - elfwalk < sizeof(elftypes)/sizeof(elftypes[0]); - elfwalk++) - fprintf(stderr, "%s(%u) ", elftypes[elfwalk].str, - elftypes[elfwalk].value); + for (elfwalk = 0; elfwalk < nitems(elftypes); elfwalk++) + fprintf(stderr, "%s(%u) ", elftypes[elfwalk].str, + elftypes[elfwalk].value); fprintf(stderr, "\n"); }