1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 16:21:26 +03:00

sd-device: move comment about NULL value

It is not intuitive, and I do not know why the function behave so.
But let's keep that behavior for compatibility, as such behavior
may be already used explicitly by callers.
This commit is contained in:
Yu Watanabe 2021-02-18 17:25:51 +09:00
parent 2a0ebc0569
commit 2f7a2e3952

View File

@ -1946,8 +1946,6 @@ static void device_remove_cached_sysattr_value(sd_device *device, const char *_k
free(hashmap_remove2(device->sysattr_values, _key, (void **) &key)); free(hashmap_remove2(device->sysattr_values, _key, (void **) &key));
} }
/* set the attribute and save it in the cache. If a NULL value is passed the
* attribute is cleared from the cache */
_public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *_value) { _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, const char *_value) {
_cleanup_free_ char *value = NULL; _cleanup_free_ char *value = NULL;
const char *syspath, *path; const char *syspath, *path;
@ -1957,7 +1955,10 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr,
assert_return(device, -EINVAL); assert_return(device, -EINVAL);
assert_return(sysattr, -EINVAL); assert_return(sysattr, -EINVAL);
/* Set the attribute and save it in the cache. */
if (!_value) { if (!_value) {
/* If input value is NULL, then clear cache and not write anything. */
device_remove_cached_sysattr_value(device, sysattr); device_remove_cached_sysattr_value(device, sysattr);
return 0; return 0;
} }