summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2022-11-04 12:45:37 +0100
committerThomas Haller <thaller@redhat.com>2022-11-08 12:53:41 +0100
commitee34eeafb9c4379828e3ac6c5b279ca9426bd99e (patch)
treebe2303191cf349fef133efeac3ae0103a3a53621
parenta275285537d156004488dbcf4085898f52b514d1 (diff)
platform: fix nmp_object_copy(id_only) for object that don't implement cmd_plobj_id_copy()
The if-else-if was wrong. It meant that if an object did not implement cmd_plobj_id_copy(), nothign was copied (for id-only). I think this code path was not actually hit, because we never clone an object only by ID. Fixes: c91a4617a102 ('nmp-object: allow missing implementations for certain virtual functions')
-rw-r--r--src/libnm-platform/nmp-object.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libnm-platform/nmp-object.c b/src/libnm-platform/nmp-object.c
index 46d6c6e758..19478cddb7 100644
--- a/src/libnm-platform/nmp-object.c
+++ b/src/libnm-platform/nmp-object.c
@@ -1317,10 +1317,9 @@ nmp_object_copy(NMPObject *dst, const NMPObject *src, gboolean id_only)
g_return_if_fail(klass == NMP_OBJECT_GET_CLASS(src));
- if (id_only) {
- if (klass->cmd_plobj_id_copy)
- klass->cmd_plobj_id_copy(&dst->object, &src->object);
- } else if (klass->cmd_obj_copy)
+ if (id_only && klass->cmd_plobj_id_copy)
+ klass->cmd_plobj_id_copy(&dst->object, &src->object);
+ else if (klass->cmd_obj_copy)
klass->cmd_obj_copy(dst, src);
else
memcpy(&dst->object, &src->object, klass->sizeof_data);