[libvirt] [PATCH v2 13/14] nodedev: Pass @def by reference to create/assign object

Peter Krempa pkrempa at redhat.com
Fri May 26 12:12:44 UTC 2017


On Thu, May 25, 2017 at 15:57:10 -0400, John Ferlan wrote:
> Since the @def is consumed by the assignment function, let's pass by
> reference instead of value and really consume it.
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/conf/virnodedeviceobj.c        | 8 ++++----
>  src/conf/virnodedeviceobj.h        | 2 +-
>  src/node_device/node_device_hal.c  | 2 +-
>  src/node_device/node_device_udev.c | 8 +++-----
>  src/test/test_driver.c             | 5 ++---
>  5 files changed, 11 insertions(+), 14 deletions(-)
> 
> diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c
> index a7e51ef..1648b33 100644
> --- a/src/conf/virnodedeviceobj.c
> +++ b/src/conf/virnodedeviceobj.c
> @@ -268,13 +268,13 @@ virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs)
>  
>  virNodeDeviceObjPtr
>  virNodeDeviceObjAssignDef(virNodeDeviceObjListPtr devs,
> -                          virNodeDeviceDefPtr def)
> +                          virNodeDeviceDefPtr *def)

I don't really like this. You can documment that this function either
consumes def always or only on success and the callers can free the
pointer. Passing the pointer to a pointer just to clear it in some cases
is overcomplicating stuff.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170526/928a22e7/attachment-0001.sig>


More information about the libvir-list mailing list