Index: contrib/elftoolchain/strings/strings.c =================================================================== --- contrib/elftoolchain/strings/strings.c +++ contrib/elftoolchain/strings/strings.c @@ -24,8 +24,8 @@ * SUCH DAMAGE. */ -#include #include +#include #include #include @@ -64,7 +64,7 @@ }; #define PRINTABLE(c) \ - ((c) >= 0 && (c) <= 255 && \ + ((c) >= 0 && (c) <= 255 && \ ((c) == '\t' || isprint((c)) || \ (encoding == ENCODING_8BIT && (c) > 127))) @@ -109,8 +109,8 @@ elf_errmsg(-1)); while ((ch = getopt_long(argc, argv, "1234567890ae:fhn:ot:Vv", - strings_longopts, NULL)) != -1) - switch((char)ch) { + strings_longopts, NULL)) != -1) { + switch ((char)ch) { case 'a': entire_file = 1; break; @@ -183,14 +183,15 @@ usage(); /* NOTREACHED */ } + } argc -= optind; argv += optind; - if (!min_len) + if (min_len == 0) min_len = 4; - if (!*argv) + if (*argv == NULL) rc = find_strings("{standard input}", 0, 0); - else while (*argv) { + else while (*argv != NULL) { if (handle_file(*argv) != 0) rc = 1; argv++; @@ -226,10 +227,10 @@ { struct stat buf; - memset(&buf, 0, sizeof(struct stat)); - (void) lseek(fd, (off_t)0, SEEK_SET); + memset(&buf, 0, sizeof(buf)); + (void)lseek(fd, 0, SEEK_SET); if (!fstat(fd, &buf)) - return (find_strings(name, (off_t)0, buf.st_size)); + return (find_strings(name, 0, buf.st_size)); return (1); } @@ -253,21 +254,21 @@ if (entire_file) return (handle_binary(name, fd)); - (void) lseek(fd, (off_t)0, SEEK_SET); + (void)lseek(fd, 0, SEEK_SET); elf = elf_begin(fd, ELF_C_READ, NULL); if (elf_kind(elf) != ELF_K_ELF) { - (void) elf_end(elf); + (void)elf_end(elf); return (handle_binary(name, fd)); } if (gelf_getehdr(elf, &elfhdr) == NULL) { - (void) elf_end(elf); + (void)elf_end(elf); warnx("%s: ELF file could not be processed", name); return (1); } if (elfhdr.e_shnum == 0 && elfhdr.e_type == ET_CORE) { - (void) elf_end(elf); + (void)elf_end(elf); return (handle_binary(name, fd)); } else { scn = NULL; @@ -281,7 +282,7 @@ } } } - (void) elf_end(elf); + (void)elf_end(elf); return (rc); } @@ -304,7 +305,7 @@ buf[i] = c; } - switch(encoding) { + switch (encoding) { case ENCODING_7BIT: case ENCODING_8BIT: rt = buf[0]; @@ -317,12 +318,12 @@ break; case ENCODING_32BIT_BIG: rt = ((long) buf[0] << 24) | ((long) buf[1] << 16) | - ((long) buf[2] << 8) | buf[3]; - break; + ((long) buf[2] << 8) | buf[3]; + break; case ENCODING_32BIT_LITTLE: rt = buf[0] | ((long) buf[1] << 8) | ((long) buf[2] << 16) | - ((long) buf[3] << 24); - break; + ((long) buf[3] << 24); + break; } return (rt); } @@ -341,63 +342,63 @@ int i; if ((obuf = (char*)calloc(1, min_len + 1)) == NULL) { - (void) fprintf(stderr, "Unable to allocate memory: %s\n", + (void)fprintf(stderr, "Unable to allocate memory: %s\n", strerror(errno)); return (1); } - (void) fseeko(stdin, offset, SEEK_SET); + (void)fseeko(stdin, offset, SEEK_SET); cur_off = offset; start_off = 0; - while(1) { + while (1) { if ((offset + size) && (cur_off >= offset + size)) break; start_off = cur_off; - memset(obuf, 0, min_len+1); + memset(obuf, 0, min_len + 1); for(i = 0; i < min_len; i++) { c = getcharacter(); if (c == EOF && feof(stdin)) goto _exit1; - if (PRINTABLE(c)) { - obuf[i] = c; - obuf[i+1] = 0; - cur_off += encoding_size; - } else { + if (PRINTABLE(c)) { + obuf[i] = c; + obuf[i + 1] = 0; + cur_off += encoding_size; + } else { if (encoding == ENCODING_8BIT && (uint8_t)c > 127) { - obuf[i] = c; - obuf[i+1] = 0; - cur_off += encoding_size; - continue; - } - cur_off += encoding_size; - break; - } + obuf[i] = c; + obuf[i + 1] = 0; + cur_off += encoding_size; + continue; + } + cur_off += encoding_size; + break; + } } if (i >= min_len && ((cur_off <= offset + size) || !(offset + size))) { if (show_filename) - printf ("%s: ", name); + printf("%s: ", name); if (show_loc) { - switch(radix) { + switch (radix) { case RADIX_DECIMAL: - (void) printf("%7ju ", + (void)printf("%7ju ", (uintmax_t)start_off); break; case RADIX_HEX: - (void) printf("%7jx ", + (void)printf("%7jx ", (uintmax_t)start_off); break; case RADIX_OCTAL: - (void) printf("%7jo ", + (void)printf("%7jo ", (uintmax_t)start_off); break; } } printf("%s", obuf); - while(1) { + while (1) { if ((offset + size) && (cur_off >= offset + size)) break; @@ -405,9 +406,9 @@ cur_off += encoding_size; if (encoding == ENCODING_8BIT && (uint8_t)c > 127) { - putchar(c); - continue; - } + putchar(c); + continue; + } if (!PRINTABLE(c) || c == EOF) break; putchar(c); @@ -436,13 +437,13 @@ void usage(void) { - (void) fprintf(stderr, USAGE_MESSAGE, ELFTC_GETPROGNAME()); + (void)fprintf(stderr, USAGE_MESSAGE, ELFTC_GETPROGNAME()); exit(EXIT_FAILURE); } void show_version(void) { - (void) printf("%s (%s)\n", ELFTC_GETPROGNAME(), elftc_version()); + (void)printf("%s (%s)\n", ELFTC_GETPROGNAME(), elftc_version()); exit(EXIT_SUCCESS); }