From d1dc82b4c29c4969393b8c4027b29ca9cc2249df Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Fri, 23 Feb 2018 18:06:02 -0500 Subject: Clean up xx There are probably like 12 commits with this title. --- bin/xx.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/xx.c b/bin/xx.c index 0d674162..e610c276 100644 --- a/bin/xx.c +++ b/bin/xx.c @@ -23,9 +23,9 @@ #include #include -static bool zero(const uint8_t *buf, size_t len) { - for (size_t i = 0; i < len; ++i) { - if (buf[i]) return false; +static bool zero(const uint8_t *ptr, size_t size) { + for (size_t i = 0; i < size; ++i) { + if (ptr[i]) return false; } return true; } @@ -43,10 +43,13 @@ static void dump(FILE *file) { uint8_t buf[options.cols]; size_t offset = 0; - for (size_t len; (len = fread(buf, 1, sizeof(buf), file)); offset += len) { - + for ( + size_t size; + (size = fread(buf, 1, sizeof(buf), file)); + offset += size + ) { if (options.skip) { - if (zero(buf, len)) { + if (zero(buf, size)) { if (!skip) printf("*\n"); skip = true; continue; @@ -65,7 +68,7 @@ static void dump(FILE *file) { printf(" "); } } - if (i < len) { + if (i < size) { printf("%02hhx ", buf[i]); } else { printf(" "); @@ -74,7 +77,7 @@ static void dump(FILE *file) { if (options.ascii) { printf(" "); - for (size_t i = 0; i < len; ++i) { + for (size_t i = 0; i < size; ++i) { if (options.group) { if (i && !(i % options.group)) { printf(" "); @@ -91,7 +94,7 @@ static void dump(FILE *file) { static void undump(FILE *file) { uint8_t byte; int match; - while (1 == (match = fscanf(file, " %hhx", &byte))) { + while (0 < (match = fscanf(file, " %hhx", &byte))) { printf("%c", byte); } if (!match) errx(EX_DATAERR, "invalid input"); @@ -99,7 +102,7 @@ static void undump(FILE *file) { int main(int argc, char *argv[]) { bool reverse = false; - char *path = NULL; + const char *path = NULL; int opt; while (0 < (opt = getopt(argc, argv, "ac:g:rsz"))) { @@ -124,7 +127,7 @@ int main(int argc, char *argv[]) { } else { dump(file); } - if (ferror(file)) err(EX_IOERR, "%s", path); + return EX_OK; } -- cgit 1.4.1 or 2023-10-11Import LibreSSL 3.8.1 upstreamJune McEnroe 2023-10-11Import LibreSSL 3.8.0June McEnroe 2023-10-11Import LibreSSL 3.7.3June McEnroe 2023-10-11Import LibreSSL 3.7.2June McEnroe 2023-10-11Import LibreSSL 3.7.1June McEnroe 2022-12-23Import LibreSSL 3.7.0June McEnroe 2022-12-23Import LibreSSL 3.6.1June McEnroe 2022-12-23Import LibreSSL 3.6.0June McEnroe 2022-07-27Import LibreSSL 3.5.3June McEnroe 2022-05-13Import LibreSSL 3.5.2June McEnroe 2022-03-21Import LibreSSL 3.5.1June McEnroe 2022-02-27doc: Note OpenSSL 3.0.0 compatibility in README 3.5.0June McEnroe 2022-02-27tls_signer: Replace ECDSA_METHOD with EC_KEY_METHODJune McEnroe 2022-02-27tls: Replace ECDSA_METHOD with EC_KEY_METHODJune McEnroe 2022-02-27Import LibreSSL 3.5.0June McEnroe 2021-11-29tls: Revert accidentally(?) reverted upstream 3.4.2June McEnroe 2021-11-29Import LibreSSL 3.4.2June McEnroe 2021-10-14Import LibreSSL 3.4.1June McEnroe 2021-09-17Import LibreSSL 3.4.0June McEnroe 2021-08-24Import LibreSSL 3.3.4June McEnroe 2021-05-25Bump version to 3.3.3p1 3.3.3p1June McEnroe 2021-05-25build: Add scripts to EXTRA_DISTJune McEnroe 2021-05-25import: Add missing scripts/wrap-compiler-for-flag-checkJune McEnroe 2021-05-08Import LibreSSL 3.3.3June McEnroe 2021-04-18build: Remove added x509_verify.3 links 3.3.2June McEnroe 2021-04-18tls: Use EC_KEY_set_ex_dataJune McEnroe 2021-04-18Import LibreSSL 3.3.2June McEnroe 2021-03-05Bump version to 3.3.1p1 3.3.1p1June McEnroe 2021-03-05build: Add OpenSSL includes to libcompatJune McEnroe 2020-12-15Import LibreSSL 3.3.1June McEnroe 2020-11-24Import LibreSSL 3.3.0June McEnroe 2020-10-22Import LibreSSL 3.2.2June McEnroe 2020-09-29Import LibreSSL 3.2.1June McEnroe 2020-09-29import: Add m4/ax_add_fortify_source.m4June McEnroe 2020-08-05build: Add README.7 to EXTRA_DIST 3.2.0June McEnroe 2020-08-03doc: Indicate that only OpenSSL 1.1.1b and newer workJune McEnroe