Remove st != NULL checks from recursor functions

In the description of 3111908b03, it says
that the functions must be able to handle st being NULL, but recurse
always passes a valid pointer. The only function that was ever passed
NULL was rm(), but this was changed to go through recurse in
2f4ab52739, so now the checks are
pointless.
This commit is contained in:
Michael Forney 2016-12-14 19:40:02 -08:00 committed by Anselm R Garbe
parent af392d1a76
commit a5612b0d08
6 changed files with 10 additions and 10 deletions

View File

@ -26,10 +26,10 @@ chgrp(const char *path, struct stat *st, void *data, struct recursor *r)
chownf = chown; chownf = chown;
} }
if (st && chownf(path, st->st_uid, gid) < 0) { if (chownf(path, st->st_uid, gid) < 0) {
weprintf("%s %s:", chownf_name, path); weprintf("%s %s:", chownf_name, path);
ret = 1; ret = 1;
} else if (st && S_ISDIR(st->st_mode)) { } else if (S_ISDIR(st->st_mode)) {
recurse(path, NULL, r); recurse(path, NULL, r);
} }
} }

View File

@ -13,11 +13,11 @@ chmodr(const char *path, struct stat *st, void *data, struct recursor *r)
{ {
mode_t m; mode_t m;
m = parsemode(modestr, st ? st->st_mode : 0, mask); m = parsemode(modestr, st->st_mode, mask);
if (chmod(path, m) < 0) { if (chmod(path, m) < 0) {
weprintf("chmod %s:", path); weprintf("chmod %s:", path);
ret = 1; ret = 1;
} else if (st && S_ISDIR(st->st_mode)) { } else if (S_ISDIR(st->st_mode)) {
recurse(path, NULL, r); recurse(path, NULL, r);
} }
} }

View File

@ -32,7 +32,7 @@ chownpwgr(const char *path, struct stat *st, void *data, struct recursor *r)
if (chownf(path, uid, gid) < 0) { if (chownf(path, uid, gid) < 0) {
weprintf("%s %s:", chownf_name, path); weprintf("%s %s:", chownf_name, path);
ret = 1; ret = 1;
} else if (st && S_ISDIR(st->st_mode)) { } else if (S_ISDIR(st->st_mode)) {
recurse(path, NULL, r); recurse(path, NULL, r);
} }
} }

6
du.c
View File

@ -39,11 +39,11 @@ du(const char *path, struct stat *st, void *total, struct recursor *r)
{ {
off_t subtotal = 0; off_t subtotal = 0;
if (st && S_ISDIR(st->st_mode)) if (S_ISDIR(st->st_mode))
recurse(path, &subtotal, r); recurse(path, &subtotal, r);
*((off_t *)total) += subtotal + nblks(st ? st->st_blocks : 0); *((off_t *)total) += subtotal + nblks(st->st_blocks);
if (!sflag && r->depth <= maxdepth && r->depth && st && (S_ISDIR(st->st_mode) || aflag)) if (!sflag && r->depth <= maxdepth && r->depth && (S_ISDIR(st->st_mode) || aflag))
printpath(subtotal + nblks(st->st_blocks), path); printpath(subtotal + nblks(st->st_blocks), path);
} }

View File

@ -13,7 +13,7 @@ int rm_status = 0;
void void
rm(const char *path, struct stat *st, void *data, struct recursor *r) rm(const char *path, struct stat *st, void *data, struct recursor *r)
{ {
if (!r->maxdepth && st && S_ISDIR(st->st_mode)) { if (!r->maxdepth && S_ISDIR(st->st_mode)) {
recurse(path, NULL, r); recurse(path, NULL, r);
if (rmdir(path) < 0) { if (rmdir(path) < 0) {

2
tar.c
View File

@ -370,7 +370,7 @@ c(const char *path, struct stat *st, void *data, struct recursor *r)
if (vflag) if (vflag)
puts(path); puts(path);
if (st && S_ISDIR(st->st_mode)) if (S_ISDIR(st->st_mode))
recurse(path, NULL, r); recurse(path, NULL, r);
} }