check returned value - Coverity complains (Simo Sorce, Red Hat)
make sure buf is always freed
replace assert with error
check for NULL - Coverity complains (Simo Sorce, Red Hat)
fix %d - Coverity complains (Simo Sorce, Red Hat)
Silence bogus unused return values - Clang complains (Simo Sorce, Red Hat)
unused variables - Clang complains (Simo Sorce, Red Hat)
possible NULLs - Clang complains (Simo Sorce, Red Hat)
fixup tabs->spaces