]> git.draconx.ca Git - upkg.git/blobdiff - test/decodeindex.c
libupkg: Fix minor type error in decodeindex test.
[upkg.git] / test / decodeindex.c
index bbe15f4ed86acfd99946453ef28d1827b6a4756b..415fa7904868598104ebed07c51cf271bc8bd1fd 100644 (file)
@@ -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);