Skip to content

Close in uartdmx is checked for return value...  #1144

@rewolff

Description

@rewolff

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) {

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions