X-Git-Url: https://git.draconx.ca/gitweb/upkg.git/blobdiff_plain/ebcf9b833bc750ce81951a3278065bbb86ecbdce..94cc6656cd266c2f0d8eb5bc1201fa091744c46c:/test/decodeindex.c diff --git a/test/decodeindex.c b/test/decodeindex.c index bbe15f4..415fa79 100644 --- a/test/decodeindex.c +++ b/test/decodeindex.c @@ -26,7 +26,7 @@ #define PROGNAME "decodeindex" static const char *progname = PROGNAME; -static const unsigned char sopts[] = "VH"; +static const char sopts[] = "VH"; static const struct option lopts[] = { { "version", 0, NULL, 'V' }, { "help", 0, NULL, 'H' }, @@ -86,6 +86,12 @@ static void print_version(void) static void print_bytes(FILE *f, int indent, void *buf, size_t n) { fprintf(f, "%*s", indent, ""); + + if (n == 0) { + printf("(empty)\n"); + return; + } + for (size_t i = 0; i < n; i++) fprintf(f, "%*s%.2hhx", i != 0, "", ((unsigned char *)buf)[i]); putc('\n', f); @@ -103,9 +109,6 @@ static int print_index(const char *hex) fprintf(stderr, "%s: invalid hex sequence: %s\n", progname, hex); goto out; - } else if (n == 0) { - fprintf(stderr, "%s: empty argument\n", progname); - goto out; } else if (n > sizeof buf) { fprintf(stderr, "%s: hex sequence too long: %s\n", progname, hex);