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

Re: [libvirt] PATCH: Fix default bus type selection for disks



"Daniel P. Berrange" <berrange redhat com> wrote:
> On Tue, May 13, 2008 at 10:31:10AM +0200, Jim Meyering wrote:
>> "Daniel P. Berrange" <berrange redhat com> wrote:
>>
>> in spite of the proliferation of casts --
>> That's not good for readability/maintainability.
>>
>> What do you think of this?
>>
>>     static inline char *xml2char(xmlChar *x) { return (char *) x; }
>>
>> The uses are still ugly, but at least they're safer:
>> (note that the parameter cannot be a "const" pointer because the
>> incoming xmlChar* is almost always non-const, as it must be, since
>> it's going to be freed).
>
> I'd suggest going one better and defining a thing wrapper around the
> xmlNodeGetProp method
>
>     char *virXMLGetProp(xmlNodePtr *node, const char *name) {
>         return (char *)xmlNodeGetProp(node, BAD_CAST name);
>     }
>
> That should let us get rid of all these casts throughout the code

Good idea.
Do you want to do it?  or shall I...

> The only potential issue would be that xmlChar * is technically supposed to
> be free via the xmlFree() method, rather than free(), but I believe they're
> defined to be identical unless special debug allocators are registered ?

Right.
When I removed some useless if-before-xmlFree tests,
Daniel Veillard assured us that xmlFree-in-libvirt
should always be "free", so this is ok.


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