Skip to content

Commit 2d2b269

Browse files
committed
OpenclDevice: Catch negative index (CID 1395110)
This fixes a warning from CoverityScan. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 98843e0 commit 2d2b269

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/opencl/openclwrapper.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -2573,11 +2573,13 @@ ds_device OpenclDevice::getDeviceSelection() {
25732573
bestDeviceIdx = d;
25742574
}
25752575
}
2576-
tprintf("[DS] Selected Device[%i]: \"%s\" (%s)\n", bestDeviceIdx + 1,
2577-
profile->devices[bestDeviceIdx].oclDeviceName,
2578-
profile->devices[bestDeviceIdx].type == DS_DEVICE_OPENCL_DEVICE
2576+
if (bestDeviceIdx >= 0) {
2577+
tprintf("[DS] Selected Device[%i]: \"%s\" (%s)\n", bestDeviceIdx + 1,
2578+
profile->devices[bestDeviceIdx].oclDeviceName,
2579+
profile->devices[bestDeviceIdx].type == DS_DEVICE_OPENCL_DEVICE
25792580
? "OpenCL"
25802581
: "Native");
2582+
}
25812583
// cleanup
25822584
// TODO: call destructor for profile object?
25832585

0 commit comments

Comments
 (0)