Re: [libvirt] [PATCH] fix python events

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

 



David Lively <dlively@xxxxxxxxxxxxxxx> wrote:
> On Fri, 2008-11-21 at 17:51 +0100, Jim Meyering wrote:
>> No big deal, but there are several debug printf uses here that look
>> like they try to print NULL pointers upon memory allocation failure.
>> It's ok with glibc's printf of course, but not for others.
>
> You're right.  Attached patch fixes those issues.  It also fixes some
> cases in which I got some printf string operands switched around ...
>
> I'm printing the (user-supplied) object names to help in debugging
> misbehaving python EventImpls (since there's no static type checking to
> catch these kinds of things).  So instead of printing "<NULL>" when we
> can't alloc the name, I'm printing something a little more helpful (the
> appropriate "generic" name).

That's better, indeed.
I prefer your NAME macro, too.
ACK, modulo syntax:

> diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py
> @@ -175,8 +185,7 @@ def main():
>
>          if h_cb != None:
>              #print "Invoking Handle CB"
> -            h_cb(0, h_fd, myPollEventToEventHandleType(revents & h_events),
> -                 h_opaque[0], h_opaque[1])
> +            h_cb(0, h_fd, myPollEventToEventHandleType(revents & h_events), h_opaque[0], h_opaque[1])

Reversed diff?  Better to split long lines,
not to join.

>          #print "DEBUG EXIT"
>          #break
> diff --git a/python/libvir.c b/python/libvir.c
> index 7d58442..fed1031 100644
> --- a/python/libvir.c
> +++ b/python/libvir.c
> @@ -35,6 +35,18 @@ extern void initcygvirtmod(void);
>  #define VIR_PY_INT_FAIL (libvirt_intWrap(-1))
>  #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0))
>
> +static char *py_str(PyObject *obj)
> +{
> +    PyObject *str = PyObject_Str(obj);
> +    if (!str) {
> +        PyErr_Print();
> +        PyErr_Clear();
> +        return NULL;
> +    };
> +    return PyString_AsString(str);
> +}
> +        <<<

Trailing white space ^^.

--
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]