Page MenuHomeFreeBSD

D17966.diff
No OneTemporary

D17966.diff

Index: head/usr.bin/brandelf/brandelf.c
===================================================================
--- head/usr.bin/brandelf/brandelf.c
+++ head/usr.bin/brandelf/brandelf.c
@@ -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 @@
{
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");
}

File Metadata

Mime Type
text/plain
Expires
Fri, Feb 28, 4:27 PM (20 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16887578
Default Alt Text
D17966.diff (2 KB)

Event Timeline