File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
IntelPresentMon/CommonUtilities/win Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 11#include " Event.h"
22#include " WinAPI.h"
33#include < stdexcept>
4+ #include < cassert>
45
56namespace pmon ::util::win
67{
@@ -39,10 +40,12 @@ namespace pmon::util::win
3940 std::optional<uint32_t > WaitOnMultipleEvents (std::span<Event::HandleType> events, bool waitAll, uint32_t milli)
4041 {
4142 const auto nEvents = (DWORD)events.size ();
43+ assert (nEvents <= MAXIMUM_WAIT_OBJECTS);
4244 const auto status = WaitForMultipleObjects (nEvents, events.data (), (BOOL)waitAll, (DWORD)milli);
43- const DWORD eventIndex = status - WAIT_OBJECT_0;
44- if (eventIndex >= 0 && eventIndex < nEvents) {
45- return eventIndex;
45+ if (status >= WAIT_OBJECT_0) {
46+ if (const DWORD eventIndex = status - WAIT_OBJECT_0; eventIndex < nEvents) {
47+ return eventIndex;
48+ }
4649 }
4750 else if (status == WAIT_TIMEOUT) {
4851 return {};
You can’t perform that action at this time.
0 commit comments