-
Notifications
You must be signed in to change notification settings - Fork 221
Description
Close is usually not checked for return value, as there is little you can do if close fails.
That said, the current code only tries to issue a warning if such happens. However... it won't work (if I am correct in reading the code).
https://github.com/OpenLightingProject/ola/blob/master/plugins/uartdmx/UartWidget.cpp#L86
Close is documented to return -1 on error, and zero on success. That means > 0 will never happen.
Maybe != 0 was intended. I personally like to check for < 0, allowing for calls to return error status-es other than -1, but for over 30 years now, most system functions are documented to return -1 on error and nothing else.... So my personal preference:
if (close(m_fd) < 0) {
probably more consistent with other code:
if (close(m_fd) != 0) {
otherwise valid:
if (close(m_fd) == -1) {