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.
This commit is contained in:
Yu Watanabe
2022-09-19 07:03:21 +09:00
parent e7f64b8962
commit bc5e8ebbfb

View 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;
}