diff mbox series

[04/60] service: Change return type of 'start_online_check'.

Message ID 20231221061734.2344286-5-gerickson@nuovations.com (mailing list archive)
State Superseded
Headers show
Series Complete 'continuous' Online Check Mode Implementation. | expand

Commit Message

Grant Erickson Dec. 21, 2023, 6:16 a.m. UTC
This changes the return type of 'start_online_check' from 'void' to
'int' to allow callers to conditionally handle its return status.
---
 src/service.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/src/service.c b/src/service.c
index 87ef3b575b1f..0c8a4bc0a0c9 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1913,28 +1913,48 @@  static bool online_check_is_enabled_check(
  *                           "online" reachability check is to be
  *                           started.
  *
+ *  @retval  0          If successful.
+ *  @retval  -EINVAL    If @a service is null or @a type is invalid.
+ *  @retval  -EPERM     If online checks are disabled via
+ *                      configuration.
+ *
  *  @sa cancel_online_check
  *  @sa complete_online_check
  *  @sa start_wispr_if_connected
  *  @sa __connman_service_wispr_start
  *
  */
-static void start_online_check(struct connman_service *service,
+static int start_online_check(struct connman_service *service,
 				enum connman_ipconfig_type type)
 {
+	int status = 0;
+
 	DBG("service %p (%s) type %d (%s) maybe start WISPr",
 		service,
 		connman_service_get_identifier(service),
 		type,
 		__connman_ipconfig_type2string(type));
 
-	if (!online_check_is_enabled_check(service))
-		return;
+	if (!service) {
+		status = -EINVAL;
+		goto done;
+	}
+
+	if (!online_check_is_enabled_check(service)) {
+		status = -EPERM;
+		goto done;
+	}
 
 	if (type == CONNMAN_IPCONFIG_TYPE_IPV6 || check_proxy_setup(service)) {
 		cancel_online_check(service, type);
-		__connman_service_wispr_start(service, type);
+
+		status = __connman_service_wispr_start(service, type);
 	}
+
+done:
+	DBG("status %d (%s)", status, strerror(-status));
+
+	return status;
 }
 
 /**