1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 23:51:28 +03:00

Merge pull request #65 from teg/enumerate-accept-null

libudev: enumerate - accept NULL parameters in add_match()
This commit is contained in:
Kay Sievers 2015-06-03 22:48:01 +02:00
commit f9748d8148
2 changed files with 31 additions and 8 deletions

View File

@ -137,7 +137,6 @@ _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumer
assert_return(enumerator, -EINVAL);
assert_return(_sysattr, -EINVAL);
assert_return(_value, -EINVAL);
if (match)
hashmap = &enumerator->match_sysattr;
@ -152,9 +151,11 @@ _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumer
if (!sysattr)
return -ENOMEM;
value = strdup(_value);
if (!value)
return -ENOMEM;
if (_value) {
value = strdup(_value);
if (!value)
return -ENOMEM;
}
r = hashmap_put(*hashmap, sysattr, value);
if (r < 0)
@ -174,7 +175,6 @@ _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enume
assert_return(enumerator, -EINVAL);
assert_return(_property, -EINVAL);
assert_return(_value, -EINVAL);
r = hashmap_ensure_allocated(&enumerator->match_property, NULL);
if (r < 0)
@ -184,9 +184,11 @@ _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enume
if (!property)
return -ENOMEM;
value = strdup(_value);
if (!value)
return -ENOMEM;
if (_value) {
value = strdup(_value);
if (!value)
return -ENOMEM;
}
r = hashmap_put(enumerator->match_property, property, value);
if (r < 0)

View File

@ -196,6 +196,9 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume
_public_ int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) {
assert_return(udev_enumerate, -EINVAL);
if (!subsystem)
return 0;
return sd_device_enumerator_add_match_subsystem(udev_enumerate->enumerator, subsystem, true);
}
@ -211,6 +214,9 @@ _public_ int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enum
_public_ int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem) {
assert_return(udev_enumerate, -EINVAL);
if (!subsystem)
return 0;
return sd_device_enumerator_add_match_subsystem(udev_enumerate->enumerator, subsystem, false);
}
@ -227,6 +233,9 @@ _public_ int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_en
_public_ int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value) {
assert_return(udev_enumerate, -EINVAL);
if (!sysattr)
return 0;
return sd_device_enumerator_add_match_sysattr(udev_enumerate->enumerator, sysattr, value, true);
}
@ -243,6 +252,9 @@ _public_ int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumer
_public_ int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value) {
assert_return(udev_enumerate, -EINVAL);
if (!sysattr)
return 0;
return sd_device_enumerator_add_match_sysattr(udev_enumerate->enumerator, sysattr, value, false);
}
@ -259,6 +271,9 @@ _public_ int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enum
_public_ int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value) {
assert_return(udev_enumerate, -EINVAL);
if (!property)
return 0;
return sd_device_enumerator_add_match_property(udev_enumerate->enumerator, property, value);
}
@ -274,6 +289,9 @@ _public_ int udev_enumerate_add_match_property(struct udev_enumerate *udev_enume
_public_ int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag) {
assert_return(udev_enumerate, -EINVAL);
if (!tag)
return 0;
return sd_device_enumerator_add_match_tag(udev_enumerate->enumerator, tag);
}
@ -335,6 +353,9 @@ _public_ int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev
_public_ int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname) {
assert_return(udev_enumerate, -EINVAL);
if (!sysname)
return 0;
return sd_device_enumerator_add_match_sysname(udev_enumerate->enumerator, sysname);
}