On Tue, May 13, 2008 at 10:31:10AM +0200, Jim Meyering wrote: > "Daniel P. Berrange" <berrange@xxxxxxxxxx> 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 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 ? Dan. -- |: Red Hat, Engineering, Boston -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list