You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.3 KiB
63 lines
2.3 KiB
8 months ago
|
From 2c6ea8a97986c58954603b587875a52b043e4d9b Mon Sep 17 00:00:00 2001
|
||
|
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||
|
Date: Mon, 9 Jan 2023 14:07:16 +0900
|
||
|
Subject: [PATCH] sd-device: do not directly access entry in sd-device object
|
||
|
|
||
|
No functional change, just refactoring.
|
||
|
|
||
|
(cherry picked from commit 1de6a49721957a85a4934ddbdf88d535774597b1)
|
||
|
|
||
|
Related: RHEL-5988
|
||
|
---
|
||
|
src/libsystemd/sd-device/device-private.c | 14 +++++++++-----
|
||
|
1 file changed, 9 insertions(+), 5 deletions(-)
|
||
|
|
||
|
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||
|
index 2c1d922ea3..9cec037237 100644
|
||
|
--- a/src/libsystemd/sd-device/device-private.c
|
||
|
+++ b/src/libsystemd/sd-device/device-private.c
|
||
|
@@ -621,7 +621,7 @@ int device_get_devlink_priority(sd_device *device, int *ret) {
|
||
|
|
||
|
int device_rename(sd_device *device, const char *name) {
|
||
|
_cleanup_free_ char *new_syspath = NULL;
|
||
|
- const char *interface;
|
||
|
+ const char *s;
|
||
|
int r;
|
||
|
|
||
|
assert(device);
|
||
|
@@ -630,7 +630,11 @@ int device_rename(sd_device *device, const char *name) {
|
||
|
if (!filename_is_valid(name))
|
||
|
return -EINVAL;
|
||
|
|
||
|
- r = path_extract_directory(device->syspath, &new_syspath);
|
||
|
+ r = sd_device_get_syspath(device, &s);
|
||
|
+ if (r < 0)
|
||
|
+ return r;
|
||
|
+
|
||
|
+ r = path_extract_directory(s, &new_syspath);
|
||
|
if (r < 0)
|
||
|
return r;
|
||
|
|
||
|
@@ -642,18 +646,18 @@ int device_rename(sd_device *device, const char *name) {
|
||
|
|
||
|
/* At the time this is called, the renamed device may not exist yet. Hence, we cannot validate
|
||
|
* the new syspath. */
|
||
|
- r = device_set_syspath(device, new_syspath, false);
|
||
|
+ r = device_set_syspath(device, new_syspath, /* verify = */ false);
|
||
|
if (r < 0)
|
||
|
return r;
|
||
|
|
||
|
- r = sd_device_get_property_value(device, "INTERFACE", &interface);
|
||
|
+ r = sd_device_get_property_value(device, "INTERFACE", &s);
|
||
|
if (r == -ENOENT)
|
||
|
return 0;
|
||
|
if (r < 0)
|
||
|
return r;
|
||
|
|
||
|
/* like DEVPATH_OLD, INTERFACE_OLD is not saved to the db, but only stays around for the current event */
|
||
|
- r = device_add_property_internal(device, "INTERFACE_OLD", interface);
|
||
|
+ r = device_add_property_internal(device, "INTERFACE_OLD", s);
|
||
|
if (r < 0)
|
||
|
return r;
|
||
|
|