Index: head/usr.bin/brandelf/brandelf.c =================================================================== --- head/usr.bin/brandelf/brandelf.c +++ head/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 @@ { 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 @@ break; case 'l': printelftypes(); - listed = 1; + listed = true; break; case 'v': /* does nothing */ @@ -91,7 +98,7 @@ case 't': if (force) errx(1, "t option incompatible with f option"); - change = 1; + change = true; strtype = optarg; break; default: @@ -99,7 +106,7 @@ } argc -= optind; argv += optind; - if (!argc) { + if (argc == 0) { if (listed) exit(0); else { @@ -114,7 +121,7 @@ usage(); } - while (argc) { + while (argc != 0) { int fd; char buffer[EI_NIDENT]; @@ -160,7 +167,7 @@ argv++; } - return retval; + return (retval); } static void @@ -176,12 +183,10 @@ { 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 @@ { 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 @@ 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"); }