X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=namedev.c;h=a5c711bdf65dd282d95ca56f74d5bca7f9856ab9;hp=c1c22a6cfbdda12b3b522386cfe50adc898d10ba;hb=69f57c6a2b94ae3b70a0ca43b46c30f8dce0a295;hpb=8f2f6e426fc4cc1fa39b864a1792428a4269b751 diff --git a/namedev.c b/namedev.c index c1c22a6cf..a5c711bdf 100644 --- a/namedev.c +++ b/namedev.c @@ -264,28 +264,30 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize, } break; case 's': - if (attr != NULL) { - tmpattr = find_sysfs_attribute(class_dev, sysfs_device, attr); - if (tmpattr == NULL) { - dbg("sysfa attribute '%s' not found", attr); - break; - } - /* strip trailing whitespace of matching value */ - if (isspace(tmpattr->value[strlen(tmpattr->value)-1])) { - i = len = strlen(tmpattr->value); - while (i > 0 && isspace(tmpattr->value[i-1])) - i--; - if (i < len) { - tmpattr->value[i] = '\0'; - dbg("remove %i trailing whitespace chars from '%s'", - len - i, tmpattr->value); - } - } - strfieldcatmax(string, tmpattr->value, maxsize); - dbg("substitute sysfs value '%s'", tmpattr->value); - } else { + if (!class_dev) + break; + if (attr == NULL) { dbg("missing attribute"); + break; + } + tmpattr = find_sysfs_attribute(class_dev, sysfs_device, attr); + if (tmpattr == NULL) { + dbg("sysfa attribute '%s' not found", attr); + break; } + /* strip trailing whitespace of matching value */ + if (isspace(tmpattr->value[strlen(tmpattr->value)-1])) { + i = len = strlen(tmpattr->value); + while (i > 0 && isspace(tmpattr->value[i-1])) + i--; + if (i < len) { + tmpattr->value[i] = '\0'; + dbg("remove %i trailing whitespace chars from '%s'", + len - i, tmpattr->value); + } + } + strfieldcatmax(string, tmpattr->value, maxsize); + dbg("substitute sysfs value '%s'", tmpattr->value); break; case '%': strfieldcatmax(string, "%", maxsize); @@ -535,7 +537,7 @@ static int match_sysfs_pairs(struct config_device *dev, struct sysfs_class_devic static int match_id(struct config_device *dev, struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device) { char path[SYSFS_PATH_MAX]; - char *temp = NULL; + char *temp; /* we have to have a sysfs device for ID to work */ if (!sysfs_device) @@ -747,15 +749,6 @@ int namedev_name_device(struct udevice *udev, struct sysfs_class_device *class_d dbg("process rule"); if (match_rule(udev, dev, class_dev, sysfs_device) == 0) { - /* FIXME: remove old style ignore rule and make OPTION="ignore" mandatory */ - if (dev->name[0] == '\0' && dev->symlink[0] == '\0' && - dev->mode == 0000 && dev->owner[0] == '\0' && dev->group[0] == '\0' && - !dev->ignore_device && !dev->partitions && !dev->ignore_remove) { - info("configured rule in '%s[%i]' applied, '%s' is ignored", - dev->config_file, dev->config_line, udev->kernel_name); - return -1; - } - /* apply options */ if (dev->ignore_device) { info("configured rule in '%s[%i]' applied, '%s' is ignored",