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