From 1abf400c63c5b69a024baf27ab187b8ca7b41167 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 3 Nov 2023 17:15:58 +0100 Subject: [PATCH] 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 --- core/libdivecomputer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/libdivecomputer.c b/core/libdivecomputer.c index 94988c516..572368fb9 100644 --- a/core/libdivecomputer.c +++ b/core/libdivecomputer.c @@ -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)