diff options
author | Kay Sievers <kay@vrfy.org> | 2015-06-03 22:48:01 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2015-06-03 22:48:01 +0200 |
commit | f9748d814899f0add06cbfdb4e5c53d6bab1aac5 (patch) | |
tree | a272fa0fd58085d0ef3b567f41790f9b712d5aff /src/libsystemd/sd-device/device-enumerator.c | |
parent | 21ee915614bbc35f4211a48f903a425caf386dbd (diff) | |
parent | 54f0b4d9a3e3e1b955d0b0021d9678571d91a5ef (diff) |
Merge pull request #65 from teg/enumerate-accept-null
libudev: enumerate - accept NULL parameters in add_match()
Diffstat (limited to 'src/libsystemd/sd-device/device-enumerator.c')
-rw-r--r-- | src/libsystemd/sd-device/device-enumerator.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 3692d46e06..7fd77e9480 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -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) |