From 57872d2a88b1a9ad5e2b5e68b940ecf187764e32 Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 27 Sep 2016 11:47:58 -0500 Subject: [PATCH] fallthrough if deviceId pointer is null Change-Id: I924996d60d0286a7be1d18881ee733459de2981c --- hipamd/src/hip_device.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hipamd/src/hip_device.cpp b/hipamd/src/hip_device.cpp index 6ea4658a4f..760e00c5f1 100644 --- a/hipamd/src/hip_device.cpp +++ b/hipamd/src/hip_device.cpp @@ -33,11 +33,15 @@ hipError_t hipGetDevice(int *deviceId) auto ctx = ihipGetTlsDefaultCtx(); - if (ctx == nullptr) { - e = hipErrorInvalidDevice; // TODO, check error code. - *deviceId = -1; - } else { - *deviceId = ctx->getDevice()->_deviceId; + if(deviceId != nullptr){ + if (ctx == nullptr) { + e = hipErrorInvalidDevice; // TODO, check error code. + *deviceId = -1; + } else { + *deviceId = ctx->getDevice()->_deviceId; + } + }else{ + e = hipErrorInvalidDevice; } return ihipLogStatus(e);