summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-05-21 13:26:52 +0000
committertrasz <trasz@FreeBSD.org>2015-05-21 13:26:52 +0000
commitb8ffded4a645a74822620d7c8c2f29c89ed42ea6 (patch)
tree598ef004e542fcf8eef481fa257f1fa9b86c7be5 /usr.sbin
parent938b0cc7dd64a0e7b911f6a093f33e93e1f6c222 (diff)
downloadFreeBSD-src-b8ffded4a645a74822620d7c8c2f29c89ed42ea6.zip
FreeBSD-src-b8ffded4a645a74822620d7c8c2f29c89ed42ea6.tar.gz
MFC r279843:
Refactor. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/autofs/common.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index 51dd552..7dccdee 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -449,6 +449,18 @@ node_expand_defined(struct node *n)
return (cumulated_error);
}
+static bool
+node_is_direct_key(const struct node *n)
+{
+
+ if (n->n_parent != NULL && n->n_parent->n_parent == NULL &&
+ strcmp(n->n_key, "/-") == 0) {
+ return (true);
+ }
+
+ return (false);
+}
+
bool
node_is_direct_map(const struct node *n)
{
@@ -460,11 +472,7 @@ node_is_direct_map(const struct node *n)
n = n->n_parent;
}
- assert(n->n_key != NULL);
- if (strcmp(n->n_key, "/-") != 0)
- return (false);
-
- return (true);
+ return (node_is_direct_key(n));
}
bool
@@ -538,11 +546,8 @@ node_path_x(const struct node *n, char *x)
* Return "/-" for direct maps only if we were asked for path
* to the "/-" node itself, not to any of its subnodes.
*/
- if (n->n_parent->n_parent == NULL &&
- strcmp(n->n_key, "/-") == 0 &&
- x[0] != '\0') {
+ if (node_is_direct_key(n) && x[0] != '\0')
return (x);
- }
assert(n->n_key[0] != '\0');
path = concat(n->n_key, '/', x);
OpenPOWER on IntegriCloud