48 lines
1.4 KiB
Diff
48 lines
1.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Date: Wed, 24 Feb 2021 00:33:20 -0600
|
|
Subject: [PATCH] libmultipath: cleanup code to strip wwid trailing spaces
|
|
|
|
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
|
|
Reviewed-by: Martin Wilck <mwilck@suse.com>
|
|
---
|
|
libmultipath/discovery.c | 11 ++++-------
|
|
1 file changed, 4 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
|
|
index 74abf34d..126a70b3 100644
|
|
--- a/libmultipath/discovery.c
|
|
+++ b/libmultipath/discovery.c
|
|
@@ -2062,11 +2062,11 @@ int
|
|
get_uid (struct path * pp, int path_state, struct udev_device *udev,
|
|
int allow_fallback)
|
|
{
|
|
- char *c;
|
|
const char *origin = "unknown";
|
|
ssize_t len = 0;
|
|
struct config *conf;
|
|
int used_fallback = 0;
|
|
+ size_t i;
|
|
|
|
if (!pp->uid_attribute && !pp->getuid) {
|
|
conf = get_multipath_config();
|
|
@@ -2119,12 +2119,9 @@ get_uid (struct path * pp, int path_state, struct udev_device *udev,
|
|
return 1;
|
|
} else {
|
|
/* Strip any trailing blanks */
|
|
- c = strchr(pp->wwid, '\0');
|
|
- c--;
|
|
- while (c && c >= pp->wwid && *c == ' ') {
|
|
- *c = '\0';
|
|
- c--;
|
|
- }
|
|
+ for (i = strlen(pp->wwid); i > 0 && pp->wwid[i-1] == ' '; i--);
|
|
+ /* no-op */
|
|
+ pp->wwid[i] = '\0';
|
|
}
|
|
condlog((used_fallback)? 1 : 3, "%s: uid = %s (%s)", pp->dev,
|
|
*pp->wwid == '\0' ? "<empty>" : pp->wwid, origin);
|
|
--
|
|
2.17.2
|
|
|