mirror of
https://github.com/systemd/systemd.git
synced 2025-01-21 22:04:01 +03:00
sd-device: make device_set_syspath() clear sysname and sysnum
Otherwise, when a new syspath is assigned to the sd-device object, sd_device_get_sysname() or _sysnum() will provide an outdated device name or number.
This commit is contained in:
parent
bb1234d1d6
commit
9a26098e90
@ -645,10 +645,6 @@ int device_rename(sd_device *device, const char *name) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Here, only clear the sysname and sysnum. They will be set when requested. */
|
||||
device->sysnum = NULL;
|
||||
device->sysname = mfree(device->sysname);
|
||||
|
||||
r = sd_device_get_property_value(device, "INTERFACE", &interface);
|
||||
if (r == -ENOENT)
|
||||
return 0;
|
||||
|
@ -249,6 +249,10 @@ int device_set_syspath(sd_device *device, const char *_syspath, bool verify) {
|
||||
|
||||
free_and_replace(device->syspath, syspath);
|
||||
device->devpath = devpath;
|
||||
|
||||
/* Unset sysname and sysnum, they will be assigned when requested. */
|
||||
device->sysnum = NULL;
|
||||
device->sysname = mfree(device->sysname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user