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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
> ---
>  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

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]