summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-02-07 15:01:31 +0100
committerGitHub <noreply@github.com>2019-02-07 15:01:31 +0100
commitad28cfebc184393c0c278708fd48e1ca650005a3 (patch)
treecc83639fc31e740d889dbe69d1109a67b0581301
parent6f2914406ad1f693f925dc25a75e5a0ed1b008e6 (diff)
parent9ffb90964f16d730d495ff160e63a24b482ec898 (diff)
downloadsystemd-ad28cfebc184393c0c278708fd48e1ca650005a3.tar.gz
Merge pull request #11655 from yuwata/fix-11652
sd-device: fix device_copy_properties()
-rw-r--r--src/libsystemd/sd-device/device-private.c4
-rw-r--r--src/libsystemd/sd-device/test-sd-device-monitor.c10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
index 2daf4ddd57..76267a1e74 100644
--- a/src/libsystemd/sd-device/device-private.c
+++ b/src/libsystemd/sd-device/device-private.c
@@ -712,13 +712,13 @@ int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
if (r < 0)
return r;
- ORDERED_HASHMAP_FOREACH_KEY(property, value, device_src->properties_db, i) {
+ ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties_db, i) {
r = device_add_property_aux(device_dst, property, value, true);
if (r < 0)
return r;
}
- ORDERED_HASHMAP_FOREACH_KEY(property, value, device_src->properties, i) {
+ ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties, i) {
r = device_add_property_aux(device_dst, property, value, false);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-device/test-sd-device-monitor.c b/src/libsystemd/sd-device/test-sd-device-monitor.c
index 287100d5d3..aa1edaaf3c 100644
--- a/src/libsystemd/sd-device/test-sd-device-monitor.c
+++ b/src/libsystemd/sd-device/test-sd-device-monitor.c
@@ -157,6 +157,15 @@ static void test_sd_device_monitor_filter_remove(sd_device *device) {
assert_se(sd_event_loop(sd_device_monitor_get_event(monitor_client)) == 100);
}
+static void test_device_copy_properties(sd_device *device) {
+ _cleanup_(sd_device_unrefp) sd_device *copy = NULL;
+
+ assert_se(device_shallow_clone(device, &copy) >= 0);
+ assert_se(device_copy_properties(copy, device) >= 0);
+
+ test_send_receive_one(copy, false, false, false);
+}
+
int main(int argc, char *argv[]) {
_cleanup_(sd_device_unrefp) sd_device *loopback = NULL, *sda = NULL;
int r;
@@ -186,6 +195,7 @@ int main(int argc, char *argv[]) {
test_subsystem_filter(loopback);
test_sd_device_monitor_filter_remove(loopback);
+ test_device_copy_properties(loopback);
r = sd_device_new_from_subsystem_sysname(&sda, "block", "sda");
if (r < 0) {