]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: use path_hash_ops to store sysattrs
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 18 Sep 2022 22:03:21 +0000 (07:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 19 Sep 2022 09:04:12 +0000 (18:04 +0900)
As the stored values are actually path. Just for safety.

This also drops unnecessary duplication of path.

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

index 13328ffd8361db3a5f60ec3e453e415b09d22a68..f2556ca4bcf0888b50fb0066d02501a0307fadcc 100644 (file)
@@ -1936,7 +1936,10 @@ static int device_sysattrs_read_all_internal(sd_device *device, const char *subd
                 if ((statbuf.st_mode & (S_IRUSR | S_IWUSR)) == 0)
                         continue;
 
-                r = set_put_strdup(&device->sysattrs, p ?: de->d_name);
+                if (p)
+                        r = set_ensure_consume(&device->sysattrs, &path_hash_ops_free, TAKE_PTR(p));
+                else
+                        r = set_put_strdup_full(&device->sysattrs, &path_hash_ops_free, de->d_name);
                 if (r < 0)
                         return r;
         }