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