Skip to content

Commit

Permalink
tar: void functions should not return anything, even void expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
E5ten committed May 30, 2020
1 parent 4a96c0d commit ec0cc62
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions toys/posix/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,18 +481,24 @@ static void extract_to_disk(void)
}

// create path before file if necessary
if (strrchr(name, '/') && mkpath(name) && errno!=EEXIST)
return perror_msg(":%s: can't mkdir", name);
if (strrchr(name, '/') && mkpath(name) && errno!=EEXIST) {
perror_msg(":%s: can't mkdir", name);
return;
}

// remove old file, if exists
if (!FLAG(k) && !S_ISDIR(ala) && unlink(name) && errno!=ENOENT)
return perror_msg("can't remove: %s", name);
if (!FLAG(k) && !S_ISDIR(ala) && unlink(name) && errno!=ENOENT) {
perror_msg("can't remove: %s", name);
return;
}

if (S_ISREG(ala)) {
// hardlink?
if (TT.hdr.link_target) {
if (link(TT.hdr.link_target, name))
return perror_msg("can't link '%s' -> '%s'", name, TT.hdr.link_target);
if (link(TT.hdr.link_target, name)) {
perror_msg("can't link '%s' -> '%s'", name, TT.hdr.link_target);
return;
}
// write contents
} else {
int fd = xcreate(name,
Expand All @@ -502,13 +508,19 @@ static void extract_to_disk(void)
else skippy(TT.hdr.size);
}
} else if (S_ISDIR(ala)) {
if ((mkdir(name, 0700) == -1) && errno != EEXIST)
return perror_msg("%s: can't create", TT.hdr.name);
if ((mkdir(name, 0700) == -1) && errno != EEXIST) {
perror_msg("%s: can't create", TT.hdr.name);
return;
}
} else if (S_ISLNK(ala)) {
if (symlink(TT.hdr.link_target, TT.hdr.name))
return perror_msg("can't link '%s' -> '%s'", name, TT.hdr.link_target);
} else if (mknod(name, ala, TT.hdr.device))
return perror_msg("can't create '%s'", name);
if (symlink(TT.hdr.link_target, TT.hdr.name)) {
perror_msg("can't link '%s' -> '%s'", name, TT.hdr.link_target);
return;
}
} else if (mknod(name, ala, TT.hdr.device)) {
perror_msg("can't create '%s'", name);
return;
}

// Set ownership
if (!FLAG(o) && !geteuid()) {
Expand Down

0 comments on commit ec0cc62

Please sign in to comment.