]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device-enumerator: add comments why trivial_hash_ops_free_free is used 18850/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 21:39:16 +0000 (06:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 21:39:33 +0000 (06:39 +0900)
Follow-up for a0887abbd8bd9f1a9a975af08e6b4a43960bb3e2.

src/libsystemd/sd-device/device-enumerator.c

index c98b029af23c84c26373e8fed865aa9d63afae71..2434fb625e58dbccdedc909097eb88e01a8124ca 100644 (file)
@@ -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;