From 0b18e14e80a5627f67eb093c556bf2fa5014718c Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 15 Oct 2020 15:57:26 -0500 Subject: Three trivial code cleanups and a comment tweak. --- lib/dirtree.c | 7 +++---- 1 file 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; -- cgit v1.2.3