Fix a potential C++/C99 ism, add a log message on error condition