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

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