]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix scoping error with "disk" variable 791/head
authorGeorge Hartzell <george.hartzell.gh1@contractors.roche.com>
Thu, 29 Sep 2016 21:30:44 +0000 (14:30 -0700)
committerGeorge Hartzell <george.hartzell.gh1@contractors.roche.com>
Thu, 29 Sep 2016 21:30:44 +0000 (14:30 -0700)
The variable named 'disk' inside the loop was hiding the variable named
'disk' at the outer level.  The outer variable was never used, get rid
of it.

Move the call to archive_read_disk_set_standard_lookup(disk) inside the
loop so that it Does What It Should.

examples/minitar/minitar.c

index 81e5e11c798537f4e04bff43b0bd51a9b4eac247..0b4b4147ca99eb3b1e2c4f77ffe345480a39f442 100644 (file)
@@ -222,7 +222,6 @@ static void
 create(const char *filename, int compress, const char **argv)
 {
        struct archive *a;
-       struct archive *disk;
        struct archive_entry *entry;
        ssize_t len;
        int fd;
@@ -253,12 +252,11 @@ create(const char *filename, int compress, const char **argv)
                filename = NULL;
        archive_write_open_filename(a, filename);
 
-       disk = archive_read_disk_new();
-#ifndef NO_LOOKUP
-       archive_read_disk_set_standard_lookup(disk);
-#endif
        while (*argv != NULL) {
                struct archive *disk = archive_read_disk_new();
+#ifndef NO_LOOKUP
+               archive_read_disk_set_standard_lookup(disk);
+#endif
                int r;
 
                r = archive_read_disk_open(disk, *argv);