summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-02-18 17:13:41 +0900
committerYoungjae Cho <y0.cho@samsung.com>2023-11-22 13:09:54 +0900
commit3681665b6641fa765539a6f4b9db002dd035c8cd (patch)
tree139d2b0bdc8c3bd0e918e5f36d6090ae4d92be4d
parenta7e168e5c1cabd22a5658406e64252ac6b52b6c8 (diff)
downloadsystemd-tizen_7.0.tar.gz
systemd-tizen_7.0.tar.bz2
systemd-tizen_7.0.zip
sd-device: do not cache an empty string but clear cache on failretizen_7.0
And propagate the original error on write. Note that some attributes are read-only. Original: upstream, https://github.com/systemd/systemd/pull/18684 Change-Id: Ia92b042cda22c9d95e56cbe500d199b649396f43 Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
-rw-r--r--src/libsystemd/sd-device/sd-device.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index c54fb2fa61..7a93125c2f 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -1851,21 +1851,9 @@ _public_ int sd_device_set_sysattr_value(sd_device *device, const char *sysattr,
r = write_string_file(path, value, WRITE_STRING_FILE_DISABLE_BUFFER | WRITE_STRING_FILE_NOFOLLOW);
if (r < 0) {
- if (r == -ELOOP)
- return -EINVAL;
- if (r == -EISDIR)
- return r;
-
- r = free_and_strdup(&value, "");
- if (r < 0)
- return r;
-
- r = device_add_sysattr_value(device, sysattr, value);
- if (r < 0)
- return r;
- TAKE_PTR(value);
-
- return -ENXIO;
+ /* On failure, clear cache entry, as we do not know how it fails. */
+ device_remove_sysattr_value(device, sysattr);
+ return r;
}
r = device_add_sysattr_value(device, sysattr, value);