chiark / gitweb /
[PATCH] libsysfs: work around a klibc bug
[elogind.git] / libsysfs / sysfs_class.c
index 59ef0be48e193024ae313da644189c47027fad24..4ea7f41c99c293410482acfed888498e47f79d27 100644 (file)
@@ -20,7 +20,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  *
  */
-#include "sysfs/libsysfs.h"
+#include "libsysfs.h"
 #include "sysfs.h"
 
 static void sysfs_close_cls_dev(void *dev)
@@ -111,7 +111,7 @@ static void set_classdev_classname(struct sysfs_class_device *cdev)
        if (c == NULL) {
                c = strstr(cdev->path, SYSFS_BLOCK_NAME);
        } else {
-               c = strstr(c, "/");
+               c = strchr(c, '/');
        }
 
        if (c == NULL)
@@ -640,6 +640,9 @@ struct sysfs_attribute *sysfs_get_classdev_attr
                        return cur;
        }
 
+       if (clsdev->directory == NULL)
+               return NULL;
+
        if (clsdev->directory->subdirs == NULL) 
                if ((sysfs_read_dir_subdirs(clsdev->directory)) != 0 ||
                    clsdev->directory->subdirs == NULL)