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

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