From bc5e8ebbfbf2f92622b5efeeb3ca98cbff8bcba3 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 19 Sep 2022 07:03:21 +0900 Subject: [PATCH] sd-device: use path_hash_ops to store sysattrs As the stored values are actually path. Just for safety. This also drops unnecessary duplication of path. --- src/libsystemd/sd-device/sd-device.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 13328ffd83..f2556ca4bc 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -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; }