]> git.draconx.ca Git - upkg.git/blobdiff - test/decodeindex.c
libupkg: Make decodeindex test accept an empty string.
[upkg.git] / test / decodeindex.c
index bbe15f4ed86acfd99946453ef28d1827b6a4756b..d3f099a6824ac66ec4efe6f1771995c9a52cc01d 100644 (file)
@@ -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);