Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 2015 09:53:16 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279843 - head/usr.sbin/autofs
Message-ID:  <201503100953.t2A9rGNl020673@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Tue Mar 10 09:53:15 2015
New Revision: 279843
URL: https://svnweb.freebsd.org/changeset/base/279843

Log:
  Refactor.
  
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/usr.sbin/autofs/common.c

Modified: head/usr.sbin/autofs/common.c
==============================================================================
--- head/usr.sbin/autofs/common.c	Tue Mar 10 09:41:48 2015	(r279842)
+++ head/usr.sbin/autofs/common.c	Tue Mar 10 09:53:15 2015	(r279843)
@@ -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 *
 	 * 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503100953.t2A9rGNl020673>