From: Yu Watanabe Date: Sun, 18 Sep 2022 22:03:21 +0000 (+0900) Subject: sd-device: use path_hash_ops to store sysattrs X-Git-Tag: v252-rc1~142^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bc5e8ebbfbf2f92622b5efeeb3ca98cbff8bcba3;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index 13328ffd836..f2556ca4bcf 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; }