]> git.ipfire.org Git - thirdparty/libvirt.git/commit
lib: Undo some g_steal_pointer() changes
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Mar 2021 16:33:14 +0000 (17:33 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 26 Mar 2021 09:11:57 +0000 (10:11 +0100)
commit5f9330e724428cd9733ac7fcd8274a2014a166d4
treead60efe93724fd6fb4b951bb29844b29e4541017
parentaf09d7a37a60e9ba5f98670e1dd0fd05bb25f786
lib: Undo some g_steal_pointer() changes

Recently, a few commits back I've switched bunch of code to
g_steal_pointer() using coccinelle. Problem was that the semantic
patch used was slightly off:

  @@
  expression a, b;
  @@

  + b = g_steal_pointer(&a);
  - b = a;
    ... when != a
  - a = NULL;

Problem is that, "... when != a" is supposed to jump over those
lines, which don't contain expression a. My idea was to replace
the following pattern too:

  ptrX = ptrY;
  if (something(ptrZ) < 0) goto error;
  ptrY = NULL;

But what I missed is that the following pattern is also matched
and replaced:

  ptrX = ptrY;
  if (something(ptrX) < 0) goto error;
  ptrY = NULL;

This is not necessarily correct - as demonstrated by our hotplug
code. The real problem is ambiguous memory ownership transfer
(functions which add device to domain def take ownership only on
success), but to not tackle the real issue let's revert those
parts.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/libxl/libxl_driver.c
src/lxc/lxc_driver.c
src/qemu/qemu_driver.c