mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-31 16:21:11 +03:00
match_attr() - copy attr value only when needed
This commit is contained in:
parent
cd94c04c51
commit
21cfb0436c
@ -1791,15 +1791,18 @@ static int match_key(struct udev_rules *rules, struct token *token, const char *
|
|||||||
|
|
||||||
static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur)
|
static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur)
|
||||||
{
|
{
|
||||||
char attr[UTIL_PATH_SIZE];
|
|
||||||
const char *key_name = &rules->buf[cur->key.attr_off];
|
const char *key_name = &rules->buf[cur->key.attr_off];
|
||||||
const char *key_value = &rules->buf[cur->key.value_off];
|
const char *key_value = &rules->buf[cur->key.value_off];
|
||||||
char value[UTIL_NAME_SIZE];
|
char value[UTIL_NAME_SIZE];
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
util_strlcpy(attr, key_name, sizeof(attr));
|
value[0] = '\0';
|
||||||
util_strlcpy(value, "", sizeof(value));
|
if (key_name[0] == '[') {
|
||||||
util_resolve_subsys_kernel(event->udev, attr, value, sizeof(value), 1);
|
char attr[UTIL_PATH_SIZE];
|
||||||
|
|
||||||
|
util_strlcpy(attr, key_name, sizeof(attr));
|
||||||
|
util_resolve_subsys_kernel(event->udev, attr, value, sizeof(value), 1);
|
||||||
|
}
|
||||||
if (value[0] == '\0') {
|
if (value[0] == '\0') {
|
||||||
const char *val;
|
const char *val;
|
||||||
|
|
||||||
@ -1807,7 +1810,7 @@ static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct
|
|||||||
if (val != NULL)
|
if (val != NULL)
|
||||||
util_strlcpy(value, val, sizeof(value));
|
util_strlcpy(value, val, sizeof(value));
|
||||||
}
|
}
|
||||||
if (value[0]=='\0')
|
if (value[0] == '\0')
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* strip trailing whitespace of value, if not asked to match for it */
|
/* strip trailing whitespace of value, if not asked to match for it */
|
||||||
|
Loading…
Reference in New Issue
Block a user