Rémi Bernon (@rbernon) commented about dlls/windows.devices.enumeration/main.c:
case DeviceWatcherStatus_Stopped: hr = E_ILLEGAL_METHOD_CALL; break; case DeviceWatcherStatus_Stopping: hr = E_ILLEGAL_METHOD_CALL; break; default: hr = E_ILLEGAL_METHOD_CALL;
- case DeviceWatcherStatus_EnumerationCompleted:
impl->status = DeviceWatcherStatus_Stopping;
hr = async_action_create( (IUnknown *)iface, device_watcher_stop_async, &async );
if (SUCCEEDED(hr)) IAsyncAction_Release( async );
case DeviceWatcherStatus_Started: impl->status = DeviceWatcherStatus_Stopping;break;
/* an async start is in progress, let it handle stopped state change */
if (impl->query)
DevCloseObjectQuery( impl->query );
The state machine should guarantee that `impl->query` is set here. What about enforcing `DevCloseObjectQuery called && query == NULL` as an invariant everywhere, like this instead:
```suggestion:-1+0 DevCloseObjectQuery( impl->query ); impl->query = NULL; ```
And remove the corresponding `watcher->query = NULL` above on `DevQueryStateClosed`.