From 80aab77c1987788561c3d60cb8eb7f7fe8dac829 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 14 Oct 2021 05:27:13 +0000 Subject: [PATCH] api: adapter: handle cases explicitly in dev query callback Signed-off-by: Jason A. Donenfeld --- api/adapter.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/api/adapter.c b/api/adapter.c index 6aa6c21..ab79f0c 100644 --- a/api/adapter.c +++ b/api/adapter.c @@ -418,15 +418,20 @@ WaitForInterfaceCallback( _In_ const DEV_QUERY_RESULT_ACTION_DATA *ActionData) { WAIT_FOR_INTERFACE_CTX *Ctx = Context; - Ctx->LastError = ERROR_SUCCESS; - if (ActionData->Action == DevQueryResultStateChange) + DWORD Ret = ERROR_SUCCESS; + switch (ActionData->Action) { + case DevQueryResultStateChange: if (ActionData->Data.State != DevQueryStateAborted) return; - Ctx->LastError = ERROR_DEVICE_NOT_AVAILABLE; - } - else if (ActionData->Action == DevQueryResultRemove) + Ret = ERROR_DEVICE_NOT_AVAILABLE; + case DevQueryResultAdd: + case DevQueryResultUpdate: + break; + default: return; + } + Ctx->LastError = Ret; SetEvent(Ctx->Event); }