From 5ba7e79885ba769f5a016631bf95c756c1c7e02c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 29 Oct 2018 15:15:25 +0900 Subject: [PATCH] udev-rules: make match_attr() take sd_device instead of udev_device --- src/udev/udev-rules.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index d5ebd3b..daa3fd2 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1673,11 +1673,9 @@ static int match_key(struct udev_rules *rules, struct token *token, const char * return -1; } -static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct udev_event *event, struct token *cur) { - const char *name; - char nbuf[UTIL_NAME_SIZE]; - const char *value; - char vbuf[UTIL_NAME_SIZE]; +static int match_attr(struct udev_rules *rules, sd_device *dev, struct udev_event *event, struct token *cur) { + char nbuf[UTIL_NAME_SIZE], vbuf[UTIL_NAME_SIZE]; + const char *name, *value; size_t len; name = rules_str(rules, cur->key.attr_off); @@ -1687,8 +1685,7 @@ static int match_attr(struct udev_rules *rules, struct udev_device *dev, struct name = nbuf; _fallthrough_; case SB_NONE: - value = udev_device_get_sysattr_value(dev, name); - if (value == NULL) + if (sd_device_get_sysattr_value(dev, name, &value) < 0) return -1; break; case SB_SUBSYS: @@ -1831,7 +1828,7 @@ int udev_rules_apply_to_event( goto nomatch; break; case TK_M_ATTR: - if (match_attr(rules, event->dev, event, cur) != 0) + if (match_attr(rules, event->dev->device, event, cur) != 0) goto nomatch; break; case TK_M_SYSCTL: { @@ -1885,7 +1882,7 @@ int udev_rules_apply_to_event( goto try_parent; break; case TK_M_ATTRS: - if (match_attr(rules, event->dev_parent, event, key) != 0) + if (match_attr(rules, event->dev_parent->device, event, key) != 0) goto try_parent; break; case TK_M_TAGS: { -- 2.7.4