Yes, I had to post one more, hopefully shorter, rant on logger.c. This has to do with “checking return values” in OpenSource code.
#ifndef MSG_NOSIGNAL # define MSG_NOSIGNAL 0 #endif if (sendmsg(ctl->fd, &message, MSG_NOSIGNAL) < 0) { logger_reopen(ctl); if (sendmsg(ctl->fd, &message, MSG_NOSIGNAL) < 0) warn(_("send message failed")); }
Code like this is rampant in OpenSource. It passes the quick and dirty teen age “code review” but it is not production quality. If Linux and the OpenSource community wants to gain respect it needs to start writing production quality code. This means real QA not automated tests run via Jenkins which test nothing.
The above code is NOT checking the return value in a production quality manner. It isn’t catching the error and reporting it via some human readable log entry. Ideally it should catch the error and report it along with the human readable text associated with the error.
Error: 12345 in blah - Severe indigestion
The hapless schmoe who has to debug this has to modify the code before they can even gain access to the error in the debugger. This code adheres to the letter of “checking the return value” without adhering to the spirit of it in a production quality manner. Snippets like this make it nigh on impossible to port OpenSource code to a regular production platform.
Scarier still are the publicly traded corporations running production systems on operating systems containing this type of code. Then they wonder how they got hacked without knowing it. Well, quite simply, because error return values weren’t checked in a production quality manner.