Skip to content

Commit adde22a

Browse files
committed
Fix coverity issues
1 parent 5df0e1f commit adde22a

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

MacHyperVSupport/Controller/HyperVControllerInterrupts.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void HyperVController::handleInterrupt(OSObject *target, void *refCon, IOService
264264
//
265265
// Check each channel for pending interrupt and invoke handler.
266266
//
267-
for (UInt32 i = 1; i <= kVMBusMaxChannels; i++) {
267+
for (UInt32 i = 1; i < kVMBusMaxChannels; i++) {
268268
if (sync_test_and_clear_bit(i, _vmbusRxEventFlags->flags32)) {
269269
_hvInterruptController->handleInterrupt(nullptr, nullptr, i);
270270
}
@@ -273,7 +273,7 @@ void HyperVController::handleInterrupt(OSObject *target, void *refCon, IOService
273273
//
274274
// Check each channel for pending interrupt and invoke handler.
275275
//
276-
for (UInt32 i = 1; i <= kVMBusMaxChannels; i++) {
276+
for (UInt32 i = 1; i < kVMBusMaxChannels; i++) {
277277
if (sync_test_and_clear_bit(i, _cpuData[cpuIndex].eventFlags[kVMBusInterruptMessage].flags32)) {
278278
_hvInterruptController->handleInterrupt(nullptr, nullptr, i);
279279
}

MacHyperVSupport/Keyboard/HyperVKeyboard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void HyperVKeyboard::dispatchUnicodeKeyboardEvent(UInt16 unicodeChar, bool isBre
108108
return;
109109
}
110110

111-
if (unicodeChar > arrsize(UnicodeToADBMap)) {
111+
if (unicodeChar >= arrsize(UnicodeToADBMap)) {
112112
HVDBGLOG("Unknown Unicode character 0x%X break: %u", unicodeChar, isBreak);
113113
return;
114114
}

MacHyperVSupport/VMBus/HyperVVMBusChannel.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "HyperVVMBus.hpp"
99

1010
VMBusChannelStatus HyperVVMBus::getVMBusChannelStatus(UInt32 channelId) {
11-
if (channelId == 0 || channelId > kVMBusMaxChannels) {
11+
if (channelId == 0 || channelId >= kVMBusMaxChannels) {
1212
HVDBGLOG("One or more incorrect arguments provided");
1313
return kVMBusChannelStatusNotPresent;
1414
}
@@ -29,7 +29,7 @@ IOReturn HyperVVMBus::openVMBusChannel(UInt32 channelId, UInt32 txBufferSize, VM
2929
//
3030
// TX and RX buffer sizes must be page-aligned.
3131
//
32-
if (channelId == 0 || channelId > kVMBusMaxChannels
32+
if (channelId == 0 || channelId >= kVMBusMaxChannels
3333
|| txBufferSize == 0 || txBuffer == nullptr
3434
|| rxBufferSize == 0 || rxBuffer == nullptr) {
3535
HVDBGLOG("One or more incorrect arguments provided");
@@ -126,7 +126,7 @@ IOReturn HyperVVMBus::closeVMBusChannel(UInt32 channelId) {
126126

127127
VMBusChannelMessageChannelClose closeMsg;
128128

129-
if (channelId == 0 || channelId > kVMBusMaxChannels) {
129+
if (channelId == 0 || channelId >= kVMBusMaxChannels) {
130130
HVDBGLOG("One or more incorrect arguments provided");
131131
return kIOReturnBadArgument;
132132
}
@@ -187,7 +187,7 @@ IOReturn HyperVVMBus::initVMBusChannelGPADL(UInt32 channelId, HyperVDMABuffer *d
187187
//
188188
// DMA buffer size must be page-aligned.
189189
//
190-
if (channelId == 0 || channelId > kVMBusMaxChannels
190+
if (channelId == 0 || channelId >= kVMBusMaxChannels
191191
|| dmaBuffer == nullptr || gpadlHandle == nullptr) {
192192
HVDBGLOG("One or more incorrect arguments provided");
193193
return kIOReturnBadArgument;
@@ -328,7 +328,7 @@ IOReturn HyperVVMBus::freeVMBusChannelGPADL(UInt32 channelId, UInt32 gpadlHandle
328328
VMBusChannelMessageGPADLTeardown gpadlTeardownMsg;
329329
VMBusChannelMessageGPADLTeardownResponse gpadlTeardownResponseMsg;
330330

331-
if (channelId == 0 || channelId > kVMBusMaxChannels) {
331+
if (channelId == 0 || channelId >= kVMBusMaxChannels) {
332332
HVDBGLOG("One or more incorrect arguments provided");
333333
return kIOReturnBadArgument;
334334
}

0 commit comments

Comments
 (0)