]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
contrib/archivetest: report archive_error_string() on error
authorMartin Matuska <martin@matuska.org>
Mon, 20 May 2019 11:24:59 +0000 (13:24 +0200)
committerMartin Matuska <martin@matuska.org>
Mon, 20 May 2019 11:24:59 +0000 (13:24 +0200)
contrib/archivetest.c

index f4a469b4a6daaa26be0af6a220e7a0fb6a65cc57..8002039ee4e283373d74fc02f87ba9819e6e7085 100644 (file)
@@ -197,7 +197,8 @@ int main(int argc, char *argv[])
                        while ((r = archive_read_data(a, buffer, 4096) > 0))
                        ;
                        if (r == ARCHIVE_FATAL) {
-                               v_print(v, "ERROR\n");
+                               v_print(v, "ERROR\nError string: %s\n",
+                                   archive_error_string(a));
                                break;
                        }
                        v_print(v, "OK");
@@ -205,10 +206,13 @@ int main(int argc, char *argv[])
                v_print(v, "\n");
                c++;
        }
-       archive_read_free(a);
 
        v_print(v, "Last return code: %s (%d)\n", errnostr(r), r);
-       if (r == ARCHIVE_EOF || r == ARCHIVE_OK)
+       if (r == ARCHIVE_EOF || r == ARCHIVE_OK) {
+               archive_read_free(a);
                exit(0);
+       }
+       v_print(v, "Error string: %s\n", archive_error_string(a));
+       archive_read_free(a);
        exit(2);
 }