Blame SOURCES/autofs-5.1.7-eliminate-some-strlen-calls-in-offset-handling.patch

49b67f
autofs-5.1.7 - eliminate some strlen calls in offset handling
49b67f
49b67f
From: Ian Kent <raven@themaw.net>
49b67f
49b67f
There are a number of places where strlen() is used to re-calculate
49b67f
the length of a string. Eliminate some of those by calculating the
49b67f
length once and passing it to the functions that do the re-calculation.
49b67f
49b67f
Signed-off-by: Ian Kent <raven@themaw.net>
49b67f
---
49b67f
 CHANGELOG    |    1 +
49b67f
 lib/mounts.c |   30 +++++++++++++++++-------------
49b67f
 2 files changed, 18 insertions(+), 13 deletions(-)
49b67f
49b67f
--- autofs-5.1.4.orig/CHANGELOG
49b67f
+++ autofs-5.1.4/CHANGELOG
49b67f
@@ -20,6 +20,7 @@
49b67f
 - fix inconsistent locking in parse_mount().
49b67f
 - remove unused mount offset list lock functions.
49b67f
 - eliminate count_mounts() from expire_proc_indirect().
49b67f
+- eliminate some strlen calls in offset handling.
49b67f
 
49b67f
 xx/xx/2018 autofs-5.1.5
49b67f
 - fix flag file permission.
49b67f
--- autofs-5.1.4.orig/lib/mounts.c
49b67f
+++ autofs-5.1.4/lib/mounts.c
49b67f
@@ -2534,10 +2534,12 @@ static int rmdir_path_offset(struct auto
49b67f
 	return ret;
49b67f
 }
49b67f
 
49b67f
-static int do_umount_offset(struct autofs_point *ap, struct mapent *oe, const char *root);
49b67f
+static int do_umount_offset(struct autofs_point *ap,
49b67f
+			    struct mapent *oe, const char *root, int start);
49b67f
 
49b67f
 static int do_umount_multi_triggers(struct autofs_point *ap,
49b67f
-				    struct mapent *me, const char *root, const char *base)
49b67f
+				    struct mapent *me, const char *root,
49b67f
+				    int start, const char *base)
49b67f
 {
49b67f
 	char path[PATH_MAX + 1];
49b67f
 	char *offset;
49b67f
@@ -2545,12 +2547,11 @@ static int do_umount_multi_triggers(stru
49b67f
 	struct list_head *mm_root, *pos;
49b67f
 	const char o_root[] = "/";
49b67f
 	const char *mm_base;
49b67f
-	int left, start;
49b67f
+	int left;
49b67f
 	unsigned int root_len;
49b67f
 	unsigned int mm_base_len;
49b67f
 
49b67f
 	left = 0;
49b67f
-	start = strlen(root);
49b67f
 
49b67f
 	mm_root = &me->multi->multi_list;
49b67f
 
49b67f
@@ -2586,13 +2587,14 @@ static int do_umount_multi_triggers(stru
49b67f
 		if (!oe || (strlen(oe->key) - start) == 1)
49b67f
 			continue;
49b67f
 
49b67f
-		left += do_umount_offset(ap, oe, root);
49b67f
+		left += do_umount_offset(ap, oe, root, start);
49b67f
 	}
49b67f
 
49b67f
 	return left;
49b67f
 }
49b67f
 
49b67f
-static int do_umount_offset(struct autofs_point *ap, struct mapent *oe, const char *root)
49b67f
+static int do_umount_offset(struct autofs_point *ap,
49b67f
+			    struct mapent *oe, const char *root, int start)
49b67f
 {
49b67f
 	char *oe_base;
49b67f
 	int left = 0;
49b67f
@@ -2601,8 +2603,8 @@ static int do_umount_offset(struct autof
49b67f
 	 * Check for and umount subtree offsets resulting from
49b67f
 	 * nonstrict mount fail.
49b67f
 	 */
49b67f
-	oe_base = oe->key + strlen(root);
49b67f
-	left += do_umount_multi_triggers(ap, oe, root, oe_base);
49b67f
+	oe_base = oe->key + start;
49b67f
+	left += do_umount_multi_triggers(ap, oe, root, start, oe_base);
49b67f
 
49b67f
 	/*
49b67f
 	 * If an offset that has an active mount has been removed
49b67f
@@ -2706,7 +2708,7 @@ int mount_multi_triggers(struct autofs_p
49b67f
 			goto cont;
49b67f
 		if (oe->age != me->multi->age) {
49b67f
 			/* Best effort */
49b67f
-			do_umount_offset(ap, oe, root);
49b67f
+			do_umount_offset(ap, oe, root, start);
49b67f
 			goto cont;
49b67f
 		}
49b67f
 
49b67f
@@ -2720,7 +2722,7 @@ int mount_multi_triggers(struct autofs_p
49b67f
 		if (ap->state == ST_READMAP && ap->flags & MOUNT_FLAG_REMOUNT) {
49b67f
 			if (oe->ioctlfd != -1 ||
49b67f
 			    is_mounted(oe->key, MNTS_REAL))
49b67f
-				mount_multi_triggers(ap, oe, key, strlen(key), base);
49b67f
+				mount_multi_triggers(ap, oe, key, key_len, base);
49b67f
 		}
49b67f
 cont:
49b67f
 		offset = cache_get_offset(base,
49b67f
@@ -2732,9 +2734,11 @@ cont:
49b67f
 
49b67f
 int umount_multi_triggers(struct autofs_point *ap, struct mapent *me, char *root, const char *base)
49b67f
 {
49b67f
-	int left;
49b67f
+	int left, start;
49b67f
+
49b67f
+	start = strlen(root);
49b67f
 
49b67f
-	left = do_umount_multi_triggers(ap, me, root, base);
49b67f
+	left = do_umount_multi_triggers(ap, me, root, start, base);
49b67f
 
49b67f
 	if (!left && me->multi == me) {
49b67f
 		/*
49b67f
@@ -2747,7 +2751,7 @@ int umount_multi_triggers(struct autofs_
49b67f
 			info(ap->logopt, "unmounting dir = %s", root);
49b67f
 			if (umount_ent(ap, root) &&
49b67f
 			    is_mounted(root, MNTS_REAL)) {
49b67f
-				if (mount_multi_triggers(ap, me, root, strlen(root), "/") < 0)
49b67f
+				if (mount_multi_triggers(ap, me, root, start, "/") < 0)
49b67f
 					warn(ap->logopt,
49b67f
 					     "failed to remount offset triggers");
49b67f
 				return ++left;