mirror of
https://github.com/systemd/systemd
synced 2024-07-25 04:05:16 +00:00
udev: rewrite token_match_attr() to make it easier for Coverity to understand
No functional change. Closes CID#1469719.
This commit is contained in:
parent
40f9fa0af4
commit
442c6bd4ba
|
@ -1771,27 +1771,28 @@ static bool token_match_attr(UdevRuleToken *token, sd_device *dev, UdevEvent *ev
|
||||||
case SUBST_TYPE_PLAIN:
|
case SUBST_TYPE_PLAIN:
|
||||||
if (sd_device_get_sysattr_value(dev, name, &value) < 0)
|
if (sd_device_get_sysattr_value(dev, name, &value) < 0)
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
|
/* remove trailing whitespace, if not asked to match for it */
|
||||||
|
if (token->attr_match_remove_trailing_whitespace) {
|
||||||
|
strscpy(vbuf, sizeof(vbuf), value);
|
||||||
|
value = delete_trailing_chars(vbuf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return token_match_string(token, value);
|
||||||
|
|
||||||
case SUBST_TYPE_SUBSYS:
|
case SUBST_TYPE_SUBSYS:
|
||||||
if (udev_resolve_subsys_kernel(name, vbuf, sizeof(vbuf), true) < 0)
|
if (udev_resolve_subsys_kernel(name, vbuf, sizeof(vbuf), true) < 0)
|
||||||
return false;
|
return false;
|
||||||
value = vbuf;
|
|
||||||
break;
|
/* remove trailing whitespace, if not asked to match for it */
|
||||||
|
if (token->attr_match_remove_trailing_whitespace)
|
||||||
|
delete_trailing_chars(vbuf, NULL);
|
||||||
|
|
||||||
|
return token_match_string(token, vbuf);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing whitespace, if not asked to match for it */
|
|
||||||
if (token->attr_match_remove_trailing_whitespace) {
|
|
||||||
if (value != vbuf) {
|
|
||||||
strscpy(vbuf, sizeof(vbuf), value);
|
|
||||||
value = vbuf;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete_trailing_chars(vbuf, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
return token_match_string(token, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_property_from_string(char *line, char **ret_key, char **ret_value) {
|
static int get_property_from_string(char *line, char **ret_key, char **ret_value) {
|
||||||
|
|
Loading…
Reference in a new issue