Blame SOURCES/0047-libmultipath-steal-the-src-string-pointer-in-merge_s.patch

ca7c20
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
ca7c20
From: Benjamin Marzinski <bmarzins@redhat.com>
ca7c20
Date: Wed, 13 Apr 2022 23:27:35 -0500
ca7c20
Subject: [PATCH] libmultipath: steal the src string pointer in merge_str()
ca7c20
ca7c20
Instead of allocating a copy when the original string is going to be
ca7c20
freed right after the merge, just steal the pointer. Also, merge_mpe()
ca7c20
can't get called with NULL arguments.
ca7c20
ca7c20
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
ca7c20
Reviewed-by: Martin Wilck <mwilck@suse.com>
ca7c20
---
ca7c20
 libmultipath/config.c | 16 +++++-----------
ca7c20
 1 file changed, 5 insertions(+), 11 deletions(-)
ca7c20
ca7c20
diff --git a/libmultipath/config.c b/libmultipath/config.c
ca7c20
index cee3bbb7..005d6b54 100644
ca7c20
--- a/libmultipath/config.c
ca7c20
+++ b/libmultipath/config.c
ca7c20
@@ -388,9 +388,9 @@ set_param_str(const char * str)
ca7c20
 }
ca7c20
 
ca7c20
 #define merge_str(s) \
ca7c20
-	if (!dst->s && src->s) { \
ca7c20
-		if (!(dst->s = set_param_str(src->s))) \
ca7c20
-			return 1; \
ca7c20
+	if (!dst->s && src->s && strlen(src->s)) { \
ca7c20
+		dst->s = src->s; \
ca7c20
+		src->s = NULL; \
ca7c20
 	}
ca7c20
 
ca7c20
 #define merge_num(s) \
ca7c20
@@ -398,7 +398,7 @@ set_param_str(const char * str)
ca7c20
 		dst->s = src->s
ca7c20
 
ca7c20
 
ca7c20
-static int
ca7c20
+static void
ca7c20
 merge_hwe (struct hwentry * dst, struct hwentry * src)
ca7c20
 {
ca7c20
 	char id[SCSI_VENDOR_SIZE+PATH_PRODUCT_SIZE];
ca7c20
@@ -450,15 +450,11 @@ merge_hwe (struct hwentry * dst, struct hwentry * src)
ca7c20
 	reconcile_features_with_options(id, &dst->features,
ca7c20
 					&dst->no_path_retry,
ca7c20
 					&dst->retain_hwhandler);
ca7c20
-	return 0;
ca7c20
 }
ca7c20
 
ca7c20
-static int
ca7c20
+static void
ca7c20
 merge_mpe(struct mpentry *dst, struct mpentry *src)
ca7c20
 {
ca7c20
-	if (!dst || !src)
ca7c20
-		return 1;
ca7c20
-
ca7c20
 	merge_str(alias);
ca7c20
 	merge_str(uid_attribute);
ca7c20
 	merge_str(getuid);
ca7c20
@@ -500,8 +496,6 @@ merge_mpe(struct mpentry *dst, struct mpentry *src)
ca7c20
 	merge_num(uid);
ca7c20
 	merge_num(gid);
ca7c20
 	merge_num(mode);
ca7c20
-
ca7c20
-	return 0;
ca7c20
 }
ca7c20
 
ca7c20
 void merge_mptable(vector mptable)