Wrong return value of _modbus_tcp_pi_connect() on failure #61

Closed
oldfaber opened this Issue May 22, 2012 · 1 comment

Projects

None yet

2 participants

Contributor

If getaddrinfo() fails inside _modbus_tcp_pi_connect() "rc" is returned at line 305.
This is not consistent with _modbus_tcp_connect that always return -1, and with the
documentation of modbus_connect().
"return rc" should be "return (-1)".

Moreover errno is not set, but this is a bigger issue, as errno is not set for
many errors.

Regards

Fabio

@stephane stephane closed this in 2dca042 May 29, 2012
Owner

Fabio,

Thank you for the report, the problem has been fixed.

errno is set explicitely by libmodbus or by the system call on Unix/Linux systems, I know the situation isn't as good on Windows. Feel free to indicate the missing errno you've catched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment