From: Yu Watanabe Date: Thu, 4 Mar 2021 21:39:16 +0000 (+0900) Subject: sd-device-enumerator: add comments why trivial_hash_ops_free_free is used X-Git-Tag: v249-rc1~512^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30e2c8c7e87c52045357a0031365a871b66ab449;p=thirdparty%2Fsystemd.git sd-device-enumerator: add comments why trivial_hash_ops_free_free is used Follow-up for a0887abbd8bd9f1a9a975af08e6b4a43960bb3e2. --- diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index c98b029af23..2434fb625e5 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -116,6 +116,8 @@ _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumer else hashmap = &enumerator->nomatch_sysattr; + /* Do not use string_has_ops_free_free or hashmap_put_strdup() here, as this may be called + * multiple times with the same sysattr but different value. */ r = hashmap_put_strdup_full(hashmap, &trivial_hash_ops_free_free, sysattr, value); if (r <= 0) return r; @@ -131,6 +133,8 @@ _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enume assert_return(enumerator, -EINVAL); assert_return(property, -EINVAL); + /* Do not use string_has_ops_free_free or hashmap_put_strdup() here, as this may be called + * multiple times with the same property but different value. */ r = hashmap_put_strdup_full(&enumerator->match_property, &trivial_hash_ops_free_free, property, value); if (r <= 0) return r;