[libvirt] [PATCH 2/3] rbd: Change from static to alloc contexts

Peter Krempa pkrempa at redhat.com
Wed Oct 5 11:39:30 UTC 2016


On Mon, Sep 26, 2016 at 08:18:30 -0400, John Ferlan wrote:

In subject: Static is not the same as stack allocated.

> Rather than use static/stack state context pointers, let's allocate and

same here.

> free the state context pointer.  In doing so, we'll shrink the code a bit
> since many routines perform the same initialization sequence.

Fair point in removing duplicity, but you did not justify the change
from stack allocated to heap allocated, just explained it.

> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  src/storage/storage_backend_rbd.c | 136 +++++++++++++++++++-------------------
>  1 file changed, 69 insertions(+), 67 deletions(-)
> 
> diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
> index 4e82232..37375c0 100644
> --- a/src/storage/storage_backend_rbd.c
> +++ b/src/storage/storage_backend_rbd.c
> @@ -224,6 +224,42 @@ virStorageBackendRBDCloseRADOSConn(virStorageBackendRBDStatePtr ptr)
>                time(0) - ptr->starttime);
>  }
>  
> +
> +static void
> +virStorageBackendRBDFreeStateContext(virStorageBackendRBDStatePtr *ptr)

The word "Context" seems a bit unnecessary in the name.

> +{
> +    if (!*ptr)
> +        return;
> +
> +    virStorageBackendRBDCloseRADOSConn(*ptr);
> +
> +    VIR_FREE(*ptr);
> +}
> +
> +
> +static virStorageBackendRBDStatePtr
> +virStorageBackendRBDAllocStateContext(virConnectPtr conn,
> +                                      virStoragePoolObjPtr pool)

Same here. Also I think we prefer the word "New" instead of "Alloc"

> +{
> +    virStorageBackendRBDStatePtr ptr;
> +
> +    if (VIR_ALLOC(ptr) < 0)
> +        return NULL;

ACK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161005/97ddfda8/attachment-0001.sig>


More information about the libvir-list mailing list