Remove trailing spaces from sysfs attributes
authorHannes Reinecke <hare@suse.de>
Fri, 13 Dec 2013 12:12:37 +0000 (13:12 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Fri, 13 Dec 2013 21:30:19 +0000 (22:30 +0100)
Some sysfs attributes may contain trailing spaces, which only
serve to confuse matters. So strip them before continuing.

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

index d5557d9..d519c02 100644 (file)
@@ -164,7 +164,7 @@ sysfs_get_##fname (struct udev_device * udev, char * buff, size_t len)      \
                return -EINVAL;                                         \
        }                                                               \
        ret = strlcpy(buff, attr, len);                                 \
-       return ret;                                                     \
+       return strchop(buff);                                           \
 }
 
 declare_sysfs_get_str(devtype);
index 5fedf03..2b41e7a 100644 (file)
 #include "vector.h"
 #include "structs.h"
 
-void
+size_t
 strchop(char *str)
 {
        int i;
 
        for (i=strlen(str)-1; i >=0 && isspace(str[i]); --i) ;
        str[++i] = '\0';
+       return strlen(str);
 }
 
 int
index 0dd72ae..4eafe6e 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef _UTIL_H
 #define _UTIL_H
 
-void strchop(char *);
+size_t strchop(char *);
 int basenamecpy (const char * src, char * dst, int);
 int filepresent (char * run);
 int get_word (char * sentence, char ** word);