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