api: adapter: handle cases explicitly in dev query callback

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-10-14 05:27:13 +00:00
parent 21958630ed
commit 80aab77c19

View File

@ -418,15 +418,20 @@ WaitForInterfaceCallback(
_In_ const DEV_QUERY_RESULT_ACTION_DATA *ActionData) _In_ const DEV_QUERY_RESULT_ACTION_DATA *ActionData)
{ {
WAIT_FOR_INTERFACE_CTX *Ctx = Context; WAIT_FOR_INTERFACE_CTX *Ctx = Context;
Ctx->LastError = ERROR_SUCCESS; DWORD Ret = ERROR_SUCCESS;
if (ActionData->Action == DevQueryResultStateChange) switch (ActionData->Action)
{ {
case DevQueryResultStateChange:
if (ActionData->Data.State != DevQueryStateAborted) if (ActionData->Data.State != DevQueryStateAborted)
return; return;
Ctx->LastError = ERROR_DEVICE_NOT_AVAILABLE; Ret = ERROR_DEVICE_NOT_AVAILABLE;
} case DevQueryResultAdd:
else if (ActionData->Action == DevQueryResultRemove) case DevQueryResultUpdate:
break;
default:
return; return;
}
Ctx->LastError = Ret;
SetEvent(Ctx->Event); SetEvent(Ctx->Event);
} }