Cleanups of dirtree_start() calls. (Don't need to feed in flag values, just
authorRob Landley <rob@landley.net>
Sun, 10 May 2015 05:21:42 +0000 (00:21 -0500)
committerRob Landley <rob@landley.net>
Sun, 10 May 2015 05:21:42 +0000 (00:21 -0500)
symfollow true/false.)

toys/posix/cp.c
toys/posix/du.c
toys/posix/find.c
toys/posix/ls.c

index df8269f..803bff8 100644 (file)
@@ -340,9 +340,8 @@ void cp_main(void)
 
     // Skip nonexistent sources
     if (rc) {
-      int symfollow = DIRTREE_SYMFOLLOW*!!(toys.optflags & (FLAG_H|FLAG_L));
-
-      if (errno != EXDEV || !(new = dirtree_start(src, symfollow)))
+      if (errno!=EXDEV ||
+        !(new = dirtree_start(src, toys.optflags&(FLAG_H|FLAG_L))))
           perror_msg("bad '%s'", src);
       else dirtree_handle_callback(new, TT.callback);
     }
index 0dea495..c72019e 100644 (file)
@@ -128,7 +128,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*!!(toys.optflags & FLAG_L));
+      return DIRTREE_COMEAGAIN|(DIRTREE_SYMFOLLOW*!!(toys.optflags&FLAG_L));
     } else TT.depth--;
   }
 
@@ -151,8 +151,8 @@ void du_main(void)
 
   // Loop over command line arguments, recursing through children
   for (args = toys.optc ? toys.optargs : noargs; *args; args++)
-    dirtree_handle_callback(dirtree_start(*args,
-      DIRTREE_SYMFOLLOW*!!(toys.optflags & (FLAG_H|FLAG_L))), do_du);
+    dirtree_handle_callback(dirtree_start(*args, toys.optflags&(FLAG_H|FLAG_L)),
+      do_du);
   if (toys.optflags & FLAG_c) print(TT.total*512, 0);
 
   if (CFG_TOYBOX_FREE) seen_inode(TT.inodes, 0);
index 73502b4..01d2999 100644 (file)
@@ -184,7 +184,7 @@ static int do_find(struct dirtree *new)
   struct double_list *argdata = TT.argdata;
   char *s, **ss;
 
-  recurse = DIRTREE_COMEAGAIN|((toys.optflags&FLAG_L) ? DIRTREE_SYMFOLLOW : 0);
+  recurse = DIRTREE_COMEAGAIN|(DIRTREE_SYMFOLLOW*!!(toys.optflags&FLAG_L));
 
   // skip . and .. below topdir, handle -xdev and -depth
   if (new) {
index 3e5d391..38db997 100644 (file)
@@ -329,7 +329,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
   } else {
     // Read directory contents. We dup() the fd because this will close it.
     indir->data = dup(dirfd);
-    dirtree_recurse(indir, filter, (flags&FLAG_L) ? DIRTREE_SYMFOLLOW : 0);
+    dirtree_recurse(indir, filter, DIRTREE_SYMFOLLOW*!!(flags&FLAG_L));
   }
 
   // Copy linked list to array and sort it. Directories go in array because