From 2d2b269e0219e55647d41136f63efb4ef5de786d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 16 Oct 2018 13:32:18 +0200 Subject: [PATCH] OpenclDevice: Catch negative index (CID 1395110) This fixes a warning from CoverityScan. Signed-off-by: Stefan Weil --- src/opencl/openclwrapper.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/opencl/openclwrapper.cpp b/src/opencl/openclwrapper.cpp index db53ca7093..cf2be4bf1e 100644 --- a/src/opencl/openclwrapper.cpp +++ b/src/opencl/openclwrapper.cpp @@ -2573,11 +2573,13 @@ ds_device OpenclDevice::getDeviceSelection() { bestDeviceIdx = d; } } - tprintf("[DS] Selected Device[%i]: \"%s\" (%s)\n", bestDeviceIdx + 1, - profile->devices[bestDeviceIdx].oclDeviceName, - profile->devices[bestDeviceIdx].type == DS_DEVICE_OPENCL_DEVICE + if (bestDeviceIdx >= 0) { + tprintf("[DS] Selected Device[%i]: \"%s\" (%s)\n", bestDeviceIdx + 1, + profile->devices[bestDeviceIdx].oclDeviceName, + profile->devices[bestDeviceIdx].type == DS_DEVICE_OPENCL_DEVICE ? "OpenCL" : "Native"); + } // cleanup // TODO: call destructor for profile object?