Return the actual libdivecomputer error code

The divecomputer_device_open() function tries all supported transports
one by one, and exits as soon as one is opened successfully. When the
end of the function is reached, the DC_STATUS_UNSUPPORTED error code is
returned.

The annoying side effect is that the actual error code returned by the
transport is ignored and changed into DC_STATUS_UNSUPPORTED. This is
very confusing while troubleshooting download problems.

Fixed by initializing the error code to DC_STATUS_UNSUPPORTED, in case
no transport is available for trying, and returning the last reported
error to caller.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
This commit is contained in:
Jef Driesen 2023-11-03 17:15:58 +01:00 committed by Michael Keller
parent 2a3c0d981f
commit 1abf400c63

View file

@ -1343,7 +1343,7 @@ static dc_status_t bluetooth_device_open(dc_context_t *context, device_data_t *d
dc_status_t divecomputer_device_open(device_data_t *data)
{
dc_status_t rc;
dc_status_t rc = DC_STATUS_UNSUPPORTED;
dc_context_t *context = data->context;
unsigned int transports, supported;
@ -1423,7 +1423,7 @@ dc_status_t divecomputer_device_open(device_data_t *data)
return rc;
}
return DC_STATUS_UNSUPPORTED;
return rc;
}
static dc_status_t sync_divecomputer_time(dc_device_t *device)