diff -urN udev-023-orig/udevinfo.c udev-023/udevinfo.c --- udev-023-orig/udevinfo.c 2004-03-25 01:09:52.000000000 +0100 +++ udev-023/udevinfo.c 2004-03-26 01:16:13.122194272 +0100 @@ -133,7 +133,7 @@ static int print_device_chain(const char *path) { struct sysfs_class_device *class_dev; - struct sysfs_class_device *class_dev_parent; + struct sysfs_class_device *class_dev_basedev; struct sysfs_attribute *attr; struct sysfs_device *sysfs_dev; struct sysfs_device *sysfs_dev_parent; @@ -166,6 +166,10 @@ goto exit; } printf("device '%s' has major:minor %s", class_dev->path, attr->value); + } else { + printf("this is not a block or char device\n"); + retval =-1; + goto exit; } /* open sysfs class device directory and print all attributes */ @@ -176,12 +180,11 @@ goto exit; } - /* get the device link (if parent exists look here) */ - class_dev_parent = sysfs_get_classdev_parent(class_dev); - if (class_dev_parent != NULL) - sysfs_dev = sysfs_get_classdev_device(class_dev_parent); - else - sysfs_dev = sysfs_get_classdev_device(class_dev); + /* if parent exists, use that instead */ + class_dev_basedev = sysfs_get_classdev_parent(class_dev) ? : class_dev; + + /* get the device link */ + sysfs_dev = sysfs_get_classdev_device(class_dev_basedev); if (sysfs_dev != NULL) printf("follow the class device's \"device\"\n");