aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-10-15 15:57:26 -0500
committerRob Landley <rob@landley.net>2020-10-15 15:57:26 -0500
commit0b18e14e80a5627f67eb093c556bf2fa5014718c (patch)
tree9add06f203143d0d0ef7f72a8bd7a76d03921c1d /lib
parent85e7f1671c28bb4808b0eb46aab9152ca2bb4bff (diff)
downloadtoybox-0b18e14e80a5627f67eb093c556bf2fa5014718c.tar.gz
Three trivial code cleanups and a comment tweak.
Diffstat (limited to 'lib')
-rw-r--r--lib/dirtree.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/dirtree.c b/lib/dirtree.c
index 3589933c..8c3b6a1c 100644
--- a/lib/dirtree.c
+++ b/lib/dirtree.c
@@ -75,7 +75,7 @@ error:
return 0;
}
-// Return path to this node, assembled recursively.
+// Return path to this node.
// Initial call can pass in NULL to plen, or point to an int initialized to 0
// to return the length of the path, or a value greater than 0 to allocate
@@ -88,9 +88,8 @@ char *dirtree_path(struct dirtree *node, int *plen)
int ii, ll, len;
ll = len = plen ? *plen : 0;
- if (!node->parent) {
- return strcpy(path = xzalloc(strlen(node->name)+ll+1), node->name);
- }
+ if (!node->parent)
+ return strcpy(xmalloc(strlen(node->name)+ll+1), node->name);
for (nn = node; nn; nn = nn->parent)
if ((ii = strlen(nn->name))) len += ii+1-(nn->name[ii-1]=='/');
if (plen) *plen = len;