diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-19 00:03:21 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-19 11:04:12 +0200 |
commit | bc5e8ebbfbf2f92622b5efeeb3ca98cbff8bcba3 (patch) | |
tree | e061e95a1544c9d1fadcbf4c6d2e10806fbb53cc | |
parent | also provide credentials in ExecStartPre (diff) | |
download | systemd-bc5e8ebbfbf2f92622b5efeeb3ca98cbff8bcba3.tar.xz systemd-bc5e8ebbfbf2f92622b5efeeb3ca98cbff8bcba3.zip |
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.
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 5 |
1 files changed, 4 insertions, 1 deletions
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; } |