[PATCH] a bug in linefeed removal
While I was adding pattern match to the LABEL method i hit a bug. We modify a string returned from libsysfs, so with every iteration is is truncated by one char: Dec 4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi' Dec 4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor' Dec 4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-ESXS ' Dec 4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-ESX' with '?IBM-ESXS' Dec 4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi' Dec 4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor' Dec 4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-ESX' Dec 4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-ES' with 'IBM-ESXS?' Dec 4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi' Dec 4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor' Dec 4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-ES' Dec 4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-E' with 'IBM-ES??' Dec 4 02:27:16 pim udev[23307]: do_label: dev->bus='scsi' sysfs_device->bus='scsi' Dec 4 02:27:16 pim udev[23307]: do_label: look for device attribute 'vendor' Dec 4 02:27:16 pim udev[23307]: do_label: xxx 'IBM-E' Dec 4 02:27:16 pim udev[23307]: do_label: compare attribute 'vendor' value 'IBM-' with 'IBM-ESXSS' I changed the behavior to remove only the line feed. 03-bug-in-linefeed-removal.diff remove only the line feed from string not every last char
This commit is contained in:
parent
da146a3e36
commit
28d6536a0f
|
@ -378,6 +378,7 @@ static int do_label(struct sysfs_class_device *class_dev, struct udevice *udev,
|
||||||
struct sysfs_attribute *tmpattr = NULL;
|
struct sysfs_attribute *tmpattr = NULL;
|
||||||
struct config_device *dev;
|
struct config_device *dev;
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
|
char *c;
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each(tmp, &config_device_list) {
|
||||||
dev = list_entry(tmp, struct config_device, node);
|
dev = list_entry(tmp, struct config_device, node);
|
||||||
|
@ -406,7 +407,9 @@ static int do_label(struct sysfs_class_device *class_dev, struct udevice *udev,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
label_found:
|
label_found:
|
||||||
tmpattr->value[strlen(tmpattr->value)-1] = 0x00;
|
c = tmpattr->value + strlen(tmpattr->value)-1;
|
||||||
|
if (*c == '\n')
|
||||||
|
*c = 0x00;
|
||||||
dbg("compare attribute '%s' value '%s' with '%s'",
|
dbg("compare attribute '%s' value '%s' with '%s'",
|
||||||
dev->sysfs_file, tmpattr->value, dev->sysfs_value);
|
dev->sysfs_file, tmpattr->value, dev->sysfs_value);
|
||||||
if (strcmp(dev->sysfs_value, tmpattr->value) != 0)
|
if (strcmp(dev->sysfs_value, tmpattr->value) != 0)
|
||||||
|
@ -578,7 +581,7 @@ int namedev_name_device(struct sysfs_class_device *class_dev, struct udevice *ud
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sysfs_device) {
|
if (sysfs_device) {
|
||||||
dbg("sysfs_device->path='%s'", sysfs_device->path);
|
dbg("sysfs_device->path='%s'", sysfs_device->path);
|
||||||
dbg("sysfs_device->bus_id='%s'", sysfs_device->bus_id);
|
dbg("sysfs_device->bus_id='%s'", sysfs_device->bus_id);
|
||||||
|
@ -642,7 +645,7 @@ done:
|
||||||
int namedev_init(void)
|
int namedev_init(void)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = namedev_init_rules();
|
retval = namedev_init_rules();
|
||||||
if (retval)
|
if (retval)
|
||||||
return retval;
|
return retval;
|
||||||
|
|
Loading…
Reference in New Issue