Re: [PATCH libvirt-python 09/14] Import VIR_ALLOC / VIR_ALLOC_N / VIR_REALLOC_N functions

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

 



On 11/12/2013 11:21 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> Import the libvirt memory allocation functions, stripping the OOM
> testing and error reporting pieces.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---

>  
> -    if (VIR_ALLOC_N_QUIET(ret, size) < 0) {
> +    if (VIR_ALLOC_N(ret, size) < 0) {
>          PyErr_NoMemory();
>          return NULL;
>      }

As an independent cleanup, we could simplify constructs like this...

> @@ -506,7 +506,7 @@ libvirt_virDomainBlockStatsFlags(PyObject *self ATTRIBUTE_UNUSED,
>      if (!nparams)
>          return PyDict_New();
>  
> -    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
> +    if (VIR_ALLOC_N(params, nparams) < 0)
>          return PyErr_NoMemory();

...into this shorter equivalent.

> +# if !STATIC_ANALYSIS
> +/* The ternary ensures that ptr is a pointer and not an integer type,
> + * while evaluating ptr only once.  This gives us extra compiler
> + * safety when compiling under gcc.  For now, we intentionally cast
> + * away const, since a number of callers safely pass const char *.

Hmm - I wonder if the python bindings are clean enough that we need not
cast away const?  But that may be better as a separate cleanup patch.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP 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]