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