X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=namedev.c;h=186a9f5cc25fdec1afa5bb4d51d71c495300d55d;hb=20f86361f48da48b08e1b73b04e22ea098f64e72;hp=cd38f25cb0979541ad42e119734b2fdb61abaa35;hpb=a27cd06c6d3c83d9906f5e1aaf8d3c4b32055830;p=elogind.git diff --git a/namedev.c b/namedev.c index cd38f25cb..186a9f5cc 100644 --- a/namedev.c +++ b/namedev.c @@ -219,6 +219,7 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys char *pos3; char *attr; int num; + int i; char c; struct sysfs_attribute *tmpattr; @@ -270,11 +271,15 @@ static void apply_format(struct udevice *udev, unsigned char *string, struct sys case 'c': if (strlen(udev->program_result) == 0) break; - if (num > 0) { + /* get part part of the result string */ + i = num; /* num syntax is deprecated and will be removed */ + if (attr != NULL) + i = atoi(attr); + if (i > 0) { strncpy(temp1, udev->program_result, sizeof(temp1)); pos2 = temp1; - while (num) { - num--; + while (i) { + i--; pos3 = strsep(&pos2, " "); if (pos3 == NULL) { dbg("requested part of result string not found"); @@ -820,7 +825,7 @@ found: /* substitute placeholder */ apply_format(udev, udev->name, class_dev, sysfs_device); apply_format(udev, udev->symlink, class_dev, sysfs_device); - + udev->partitions = dev->partitions; done: perm = find_perm(udev->name); if (perm) {