From 90480ab1d96c2306f7b9a2006f030e86954b123e Mon Sep 17 00:00:00 2001 From: Carlos Rafael Giani Date: Sun, 20 Nov 2022 23:04:30 +0100 Subject: [PATCH] comboctl-main: Add more argument checks to Pump.connect() Signed-off-by: Carlos Rafael Giani --- .../src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt index 2e1dbaa150..a4e403cd42 100644 --- a/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt +++ b/pump/combov2/comboctl/src/commonMain/kotlin/info/nightscout/comboctl/main/Pump.kt @@ -899,6 +899,7 @@ class Pump( */ suspend fun connect(maxNumAttempts: Int? = DEFAULT_MAX_NUM_REGULAR_CONNECT_ATTEMPTS) { check(stateFlow.value == State.Disconnected) { "Attempted to connect to pump in the ${stateFlow.value} state" } + check((maxNumAttempts == null) || (maxNumAttempts > 0)) val actualMaxNumAttempts = maxNumAttempts ?: Int.MAX_VALUE