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

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