Libvirt Hacking Guidelines -------------------------- 1. Apply sizeof to the return variable, not the type. eg Instead of SomeType *foo; .... foo = malloc(sizeof(SomeType)) Use SomeType *foo; foo = malloc(sizeof(*foo)) So if foo's type is changed in future it avoids having to search for & fixup all malloc statements. 2. Do not use conditionals in front of 'free'. eg Instead of if (foo) free(foo) Use free(foo) 3. Include "config.h" in all source files eg #include "config.h" 4. Indent in 4 space units, without tabs eg Add this at end of every file for VIM & Emacs /* * vim: set tabstop=4: * vim: set shiftwidth=4: * vim: set expandtab: */ /* * Local variables: * indent-tabs-mode: nil * c-indent-level: 4 * c-basic-offset: 4 * tab-width: 4 * End: */ 5. Ensure any user visible strings are marked for translation eg wrap all strings with _(...) virXendError(xend, VIR_ERR_INTERNAL_ERROR, _("domain information incomplete, missing domid"));