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 <bmarz...@redhat.com>
---
 libmultipath/structs.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

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 *
-- 
2.43.0


Reply via email to