libmultipath: remove strcmp_chomp()
authorHannes Reinecke <hare@suse.de>
Thu, 27 May 2010 13:02:56 +0000 (15:02 +0200)
committerHannes Reinecke <hare@suse.de>
Tue, 3 May 2011 11:58:02 +0000 (13:58 +0200)
We can as well sanitize the strings before calling
find_path_by_devt(), thus removing the need for
strcmp_chomp() altogether.

Signed-off-by: Hannes Reinecke <hare@suse.de>
libmultipath/configure.c
libmultipath/structs.c
libmultipath/util.c
libmultipath/util.h

index 95406a5..520b5eb 100644 (file)
@@ -644,6 +644,7 @@ get_refwwid (char * dev, enum devtypes dev_type, vector pathvec)
        }
 
        if (dev_type == DEV_DEVT) {
+               strchop(dev);
                pp = find_path_by_devt(pathvec, dev);
                
                if (!pp) {
index 25a5a0e..a84c509 100644 (file)
@@ -319,7 +319,7 @@ find_path_by_dev (vector pathvec, char * dev)
                return NULL;
 
        vector_foreach_slot (pathvec, pp, i)
-               if (!strcmp_chomp(pp->dev, dev))
+               if (!strcmp(pp->dev, dev))
                        return pp;
 
        condlog(3, "%s: not found in pathvec", dev);
@@ -336,7 +336,7 @@ find_path_by_devt (vector pathvec, char * dev_t)
                return NULL;
 
        vector_foreach_slot (pathvec, pp, i)
-               if (!strcmp_chomp(pp->dev_t, dev_t))
+               if (!strcmp(pp->dev_t, dev_t))
                        return pp;
 
        condlog(3, "%s: not found in pathvec", dev_t);
index ebe06dc..2b24885 100644 (file)
@@ -9,26 +9,6 @@
 
 #define PARAMS_SIZE 255
 
-int
-strcmp_chomp(char *str1, char *str2)
-{
-       int i;
-       char s1[PARAMS_SIZE],s2[PARAMS_SIZE];
-
-       if(!str1 || !str2)
-               return 1;
-
-       strncpy(s1, str1, PARAMS_SIZE);
-       strncpy(s2, str2, PARAMS_SIZE);
-
-       for (i=strlen(s1)-1; i >=0 && isspace(s1[i]); --i) ;
-       s1[++i] = '\0';
-       for (i=strlen(s2)-1; i >=0 && isspace(s2[i]); --i) ;
-       s2[++i] = '\0';
-
-       return(strcmp(s1,s2));
-}
-
 void
 strchop(char *str)
 {
index 52f2578..ceab398 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef _UTIL_H
 #define _UTIL_H
 
-int strcmp_chomp(char *, char *);
 void strchop(char *);
 void basenamecpy (char * src, char * dst);
 int filepresent (char * run);