diff mbox series

[v2,10/18] libmultipath: print error when find_mp_by_str() fails.

Message ID 20240103175643.18438-11-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series change how multipathd deletes maps plus cleanups | expand

Commit Message

Benjamin Marzinski Jan. 3, 2024, 5:56 p.m. UTC
None of the callers of find_mp_by_str() print any message if they fail
because the map name is invalid. Print one in find_mp_by_str() to save
the effort of adding it to all the callers.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
 libmultipath/structs.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libmultipath/structs.c b/libmultipath/structs.c
index 1b305fd1..74e31a13 100644
--- a/libmultipath/structs.c
+++ b/libmultipath/structs.c
@@ -480,11 +480,16 @@  struct multipath *
 find_mp_by_str (const struct _vector *mpvec, const char * str)
 {
 	int minor;
+	struct multipath *mpp;
 
 	if (sscanf(str, "dm-%d", &minor) == 1)
-		return find_mp_by_minor(mpvec, minor);
+		mpp = find_mp_by_minor(mpvec, minor);
 	else
-		return find_mp_by_alias(mpvec, str);
+		mpp = find_mp_by_alias(mpvec, str);
+
+	if (!mpp)
+		condlog(2, "%s: invalid map name.", str);
+	return mpp;
 }
 
 struct path *