aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/du.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2023-03-03 15:21:06 -0600
committerRob Landley <rob@landley.net>2023-03-03 15:21:06 -0600
commitb367482e9c102f49001a7e2d1ddb048bdce8b06e (patch)
treef4c498463564b545fcee9408899925db8dc2d29a /toys/posix/du.c
parent078e95bba4fa0ce2aaf3e17502bba05b8551a93d (diff)
downloadtoybox-b367482e9c102f49001a7e2d1ddb048bdce8b06e.tar.gz
Change FLAG(x) macros to always return 0 or 1. Treewide audit of FLAG()
users to make sure nobody NEEDED FLAG(x) to return the masked bit value, and to remove now-redundant !!, with a number of in-passing cleanups while I was there. I think I fixed an actual bug in patch.c (-R depended on the flag value but commit 6f6b7614e463 changed it, so "+-"[FLAG(R)] was comparing against the NUL terminator when measuring fuzz) but we didn't have a test for "fuzz autodetection". And there was another bug in tar.c where DIRTREE_BREADTH was assigned to a local variable... and then not used. But the test passed? (Not sure the flag's needed at the top level, added a comment to the test suite to remind me to revisit that.) While I was there, capitalize TODO comments so they're easier to grep for.
Diffstat (limited to 'toys/posix/du.c')
-rw-r--r--toys/posix/du.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/toys/posix/du.c b/toys/posix/du.c
index 05dea096..8bf9575d 100644
--- a/toys/posix/du.c
+++ b/toys/posix/du.c
@@ -114,8 +114,7 @@ static int do_du(struct dirtree *node)
else if (!dirtree_notdotdot(node)) return 0;
// detect swiching filesystems
- if (FLAG(x) && (TT.st_dev != node->st.st_dev))
- return 0;
+ if (FLAG(x) && TT.st_dev != node->st.st_dev) return 0;
// Don't loop endlessly on recursive directory symlink
if (FLAG(L)) {
@@ -132,7 +131,7 @@ static int do_du(struct dirtree *node)
if (S_ISDIR(node->st.st_mode)) {
if (!node->again) {
TT.depth++;
- return DIRTREE_COMEAGAIN|(DIRTREE_SYMFOLLOW*!!FLAG(L));
+ return DIRTREE_COMEAGAIN|DIRTREE_SYMFOLLOW*FLAG(L);
} else TT.depth--;
}