chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3202873
)
cleanup $attr{} substitution
author
Kay Sievers
<kay.sievers@vrfy.org>
Sat, 6 Jun 2009 02:54:41 +0000
(
04:54
+0200)
committer
Kay Sievers
<kay.sievers@vrfy.org>
Sat, 6 Jun 2009 02:54:41 +0000
(
04:54
+0200)
udev/udev-event.c
patch
|
blob
|
history
diff --git
a/udev/udev-event.c
b/udev/udev-event.c
index 3f69c0bb7a86c35ed8b3d1eb737e2d4a37d355fd..2f32805f30d9b57885a12e847d778248adf72fa4 100644
(file)
--- a/
udev/udev-event.c
+++ b/
udev/udev-event.c
@@
-180,6
+180,8
@@
subst:
attrbuf[i] = '\0';
from += i+1;
attr = attrbuf;
attrbuf[i] = '\0';
from += i+1;
attr = attrbuf;
+ } else {
+ attr = NULL;
}
switch (type) {
}
switch (type) {
@@
-276,8
+278,8
@@
subst:
break;
}
case SUBST_ATTR: {
break;
}
case SUBST_ATTR: {
- const char *val;
- char v
alue
[UTIL_NAME_SIZE];
+ const char *val
ue = NULL
;
+ char v
buf
[UTIL_NAME_SIZE];
size_t len;
int count;
size_t len;
int count;
@@
-286,36
+288,32
@@
subst:
break;
}
break;
}
- value[0] = '\0';
- /* read the value specified by "[dmi/id]product_name" */
-
util_resolve_subsys_kernel(event->udev, attr, value, sizeof(value), 1)
;
+ /* try to read the value specified by "[dmi/id]product_name" */
+ if (util_resolve_subsys_kernel(event->udev, attr, vbuf, sizeof(vbuf), 1) == 0)
+
value = vbuf
;
- /* try to read attribute of the current device */
- if (value[0] == '\0') {
- val = udev_device_get_sysattr_value(event->dev, attr);
- if (val != NULL)
- util_strscpy(value, sizeof(value), val);
- }
+ /* try to read the attribute the device */
+ if (value == NULL)
+ value = udev_device_get_sysattr_value(event->dev, attr);
/* try to read the attribute of the parent device, other matches have selected */
/* try to read the attribute of the parent device, other matches have selected */
- if (value[0] == '\0' && event->dev_parent != NULL && event->dev_parent != event->dev) {
- val = udev_device_get_sysattr_value(event->dev_parent, attr);
- if (val != NULL)
- util_strscpy(value, sizeof(value), val);
- }
+ if (value == NULL && event->dev_parent != NULL && event->dev_parent != event->dev)
+ value = udev_device_get_sysattr_value(event->dev_parent, attr);
- if (value
[0]=='\0'
)
+ if (value
== NULL
)
break;
/* strip trailing whitespace, and replace unwanted characters */
break;
/* strip trailing whitespace, and replace unwanted characters */
- len = strlen(value);
- while (len > 0 && isspace(value[--len]))
- value[len] = '\0';
- count = udev_util_replace_chars(value, UDEV_ALLOWED_CHARS_INPUT);
+ if (value != vbuf)
+ util_strscpy(vbuf, sizeof(vbuf), value);
+ len = strlen(vbuf);
+ while (len > 0 && isspace(vbuf[--len]))
+ vbuf[len] = '\0';
+ count = udev_util_replace_chars(vbuf, UDEV_ALLOWED_CHARS_INPUT);
if (count > 0)
info(event->udev, "%i character(s) replaced\n" , count);
if (count > 0)
info(event->udev, "%i character(s) replaced\n" , count);
- l = util_strpcpy(&s, l, v
alue
);
- dbg(event->udev, "substitute sysfs value '%s'\n", v
alue
);
+ l = util_strpcpy(&s, l, v
buf
);
+ dbg(event->udev, "substitute sysfs value '%s'\n", v
buf
);
break;
}
case SUBST_PARENT: {
break;
}
case SUBST_PARENT: {