summaryrefslogtreecommitdiffstats
path: root/usr.sbin/autofs
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-03-09 11:59:58 +0000
committertrasz <trasz@FreeBSD.org>2015-03-09 11:59:58 +0000
commit8822ff21ceb6b87a0a94f48793723433190908fd (patch)
tree8e0f622e45f6151b012842bf6e9599a71bca7712 /usr.sbin/autofs
parent9ae74daa194ec4ee26207f3bc373eae41a8e39dd (diff)
downloadFreeBSD-src-8822ff21ceb6b87a0a94f48793723433190908fd.zip
FreeBSD-src-8822ff21ceb6b87a0a94f48793723433190908fd.tar.gz
Minor optimization/cleanup in node_path(); no functional changes.
MFC after: 1 month Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin/autofs')
-rw-r--r--usr.sbin/autofs/common.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index 8ace69d..8c455c4 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -561,7 +561,6 @@ static char *
node_path_x(const struct node *n, char *x)
{
char *path;
- size_t len;
if (n->n_parent == NULL)
return (x);
@@ -580,14 +579,6 @@ node_path_x(const struct node *n, char *x)
path = separated_concat(n->n_key, x, '/');
free(x);
- /*
- * Strip trailing slash.
- */
- len = strlen(path);
- assert(len > 0);
- if (path[len - 1] == '/')
- path[len - 1] = '\0';
-
return (node_path_x(n->n_parent, path));
}
@@ -598,8 +589,19 @@ node_path_x(const struct node *n, char *x)
char *
node_path(const struct node *n)
{
+ char *path;
+ size_t len;
+
+ path = node_path_x(n, checked_strdup(""));
+
+ /*
+ * Strip trailing slash, unless the whole path is "/".
+ */
+ len = strlen(path);
+ if (len > 1 && path[len - 1] == '/')
+ path[len - 1] = '\0';
- return (node_path_x(n, checked_strdup("")));
+ return (path);
}
static char *
OpenPOWER on IntegriCloud