[libvirt] [PATCH 07/11] Replace virStreamFree with virObjectUnref

Peter Krempa pkrempa at redhat.com
Tue Dec 2 15:31:28 UTC 2014


On 12/01/14 16:56, John Ferlan wrote:
> Since virStreamFree will call virObjectUnref anyway, let's just use that
> directly so as to avoid the possibility that we inadvertently clear out
> a pending error message when using the public API.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  cfg.mk                     | 4 ++--
>  daemon/remote.c            | 2 +-
>  daemon/stream.c            | 2 +-
>  src/conf/virchrdev.c       | 4 ++--
>  src/fdstream.c             | 2 +-
>  src/remote/remote_driver.c | 2 +-
>  6 files changed, 8 insertions(+), 8 deletions(-)
> 

> diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c
> index 022fe71..3e7df7e 100644
> --- a/src/conf/virchrdev.c
> +++ b/src/conf/virchrdev.c

> @@ -439,7 +439,7 @@ int virChrdevOpen(virChrdevsPtr devs,
>      if (added)
>          virHashRemoveEntry(devs->hash, path);
>      else
> -        virStreamFree(st);
> +        virObjectUnref(st);
>  
>      virSetError(savedError);
>      virFreeError(savedError);

virHashRemoveEntry doesn't taint the error so you can get rid of the
code that saves error and returns it

> diff --git a/src/fdstream.c b/src/fdstream.c
> index 9ff7e2a..a020cdd 100644
> --- a/src/fdstream.c
> +++ b/src/fdstream.c
> @@ -188,7 +188,7 @@ static void virFDStreamEvent(int watch ATTRIBUTE_UNUSED,
>  static void virFDStreamCallbackFree(void *opaque)
>  {
>      virStreamPtr st = opaque;
> -    virStreamFree(st);
> +    virObjectUnref(st);

virObjectUnref() takes void * so you could get rid of the intermediate
variable.

>  }
>  
>  

ACK with or without changes.

Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141202/d35b3f60/attachment-0001.sig>


More information about the libvir-list mailing list