|
|
|
|
|
|
|
|
|
|
xen-devel
Re: [Xen-devel] [PATCH 08 of 10] xen.lowlevel.xl: Return None on empty d
On Thu, 2011-06-02 at 23:35 +0100, Marek Marczykowski wrote:
> # HG changeset patch
> # User Marek Marczykowski <marmarek@xxxxxxxxxxxx>
> # Date 1306963128 -7200
> # Node ID d03bd7a830bff8162b6b0564d27b3f36ca52d8bb
> # Parent 6811aa543e69379557ff7391ea3db8a5e7f7dde0
> xen.lowlevel.xl: Return None on empty domain name
>
> Previously PyString_FromString(NULL) was called, which caused assertion
> failure.
>
> Signed-off-by: Marek Marczykowski <marmarek@xxxxxxxxxxxx>
>
> diff --git a/tools/python/xen/lowlevel/xl/xl.c
> b/tools/python/xen/lowlevel/xl/xl.c
> --- a/tools/python/xen/lowlevel/xl/xl.c
> +++ b/tools/python/xen/lowlevel/xl/xl.c
> @@ -418,8 +418,11 @@
> return NULL;
>
> domname = libxl_domid_to_name(&self->ctx, domid);
> - ret = PyString_FromString(domname);
> - free(domname);
> + if (domname) {
> + ret = PyString_FromString(domname);
> + free(domname);
> + } else
> + return Py_None;
Please do
ret = Py_None;
instead. Having a mixture the single return location and individual
returns isn't nice.
Personally I'd just initialise ret to Py_None in the first place and
omit the else.
Ian.
>
> return ret;
> }
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
|
|
|
|