Author: oshogbo
Date: Sun Nov 18 12:03:12 2018
New Revision: 340567
URL: https://svnweb.freebsd.org/changeset/base/340567

Log:
  brandelf: fix style nits
  
  No functional change intended.
  
  Reviewed by:  emaste, markj
  Differential Revision:        https://reviews.freebsd.org/D17966

Modified:
  head/usr.bin/brandelf/brandelf.c

Modified: head/usr.bin/brandelf/brandelf.c
==============================================================================
--- head/usr.bin/brandelf/brandelf.c    Sun Nov 18 11:55:58 2018        
(r340566)
+++ head/usr.bin/brandelf/brandelf.c    Sun Nov 18 12:03:12 2018        
(r340567)
@@ -32,11 +32,13 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/elf_common.h>
 #include <sys/errno.h>
+
 #include <err.h>
 #include <fcntl.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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 @@ fail:
                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");
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to