diff --git a/core/helpers/debug_helpers.h b/core/helpers/debug_helpers.h index d6445fe43c..43a7119b13 100644 --- a/core/helpers/debug_helpers.h +++ b/core/helpers/debug_helpers.h @@ -28,6 +28,8 @@ #endif // _DEBUG #endif // !DEBUG_BREAK_IF +#define UNUSED_VARIABLE(x) ((void)(x)) + namespace NEO { void debugBreak(int line, const char *file); [[noreturn]] void abortUnrecoverable(int line, const char *file); diff --git a/core/helpers/file_io.cpp b/core/helpers/file_io.cpp index 628d03f78a..aaf2adfc04 100644 --- a/core/helpers/file_io.cpp +++ b/core/helpers/file_io.cpp @@ -37,7 +37,7 @@ std::unique_ptr loadDataFromFile( memset(ret.get(), 0x00, nsize + 1); auto read = fread(ret.get(), sizeof(unsigned char), nsize, fp); DEBUG_BREAK_IF(read != nsize); - ((void)(read)); + UNUSED_VARIABLE(read); } else { nsize = 0; } diff --git a/core/utilities/reference_tracked_object.h b/core/utilities/reference_tracked_object.h index 5dc3a0002e..b5161fec9f 100644 --- a/core/utilities/reference_tracked_object.h +++ b/core/utilities/reference_tracked_object.h @@ -30,7 +30,7 @@ class RefCounter { void inc() { CT curr = ++val; DEBUG_BREAK_IF(curr < 1); - ((void)(curr)); + UNUSED_VARIABLE(curr); } bool dec() { diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 96a501bcdf..601378f6f3 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -179,7 +179,7 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform, pPlatform = constructPlatform(); bool ret = pPlatform->initialize(); DEBUG_BREAK_IF(ret != true); - ((void)(ret)); + UNUSED_VARIABLE(ret); } DEBUG_BREAK_IF(pPlatform->isInitialized() != true); diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index 8df926989f..3ce06560d0 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -1415,7 +1415,7 @@ cl_int Kernel::setArgImmediate(uint32_t argIndex, auto pSrc = ptrOffset(argVal, kernelArgPatchInfo.sourceOffset); DEBUG_BREAK_IF(!(ptrOffset(pDst, kernelArgPatchInfo.size) <= crossThreadDataEnd)); - ((void)(crossThreadDataEnd)); + UNUSED_VARIABLE(crossThreadDataEnd); if (kernelArgPatchInfo.sourceOffset < argSize) { size_t maxBytesToCopy = argSize - kernelArgPatchInfo.sourceOffset; diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index bf5d518292..e6acb1c1fc 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -282,7 +282,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A auto ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_CREATE, &create); DEBUG_BREAK_IF(ret != 0); - ((void)(ret)); + UNUSED_VARIABLE(ret); auto bo = new (std::nothrow) BufferObject(this->drm, create.handle, allocationData.rootDeviceIndex); if (!bo) { @@ -293,7 +293,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A auto ret2 = bo->setTiling(I915_TILING_Y, static_cast(allocationData.imgInfo->rowPitch)); DEBUG_BREAK_IF(ret2 != true); - ((void)(ret2)); + UNUSED_VARIABLE(ret2); auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo, nullptr, gpuRange, allocationData.imgInfo->size, MemoryPool::SystemCpuInaccessible); allocation->setDefaultGmm(gmm.release()); @@ -412,7 +412,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o int err = errno; printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, "ioctl(PRIME_FD_TO_HANDLE) failed with %d. errno=%d(%s)\n", ret, err, strerror(err)); DEBUG_BREAK_IF(ret != 0); - ((void)(ret)); + UNUSED_VARIABLE(ret); return nullptr; } @@ -448,7 +448,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o ret = this->drm->ioctl(DRM_IOCTL_I915_GEM_GET_TILING, &getTiling); DEBUG_BREAK_IF(ret != 0); - ((void)(ret)); + UNUSED_VARIABLE(ret); if (getTiling.tiling_mode == I915_TILING_NONE) { properties.imgInfo->linearStorage = true; @@ -545,7 +545,7 @@ uint64_t DrmMemoryManager::getSystemSharedMemory() { getContextParam.param = I915_CONTEXT_PARAM_GTT_SIZE; auto ret = drm->ioctl(DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &getContextParam); DEBUG_BREAK_IF(ret != 0); - ((void)(ret)); + UNUSED_VARIABLE(ret); uint64_t gpuMemorySize = getContextParam.value; return std::min(hostMemorySize, gpuMemorySize); @@ -603,7 +603,7 @@ void DrmMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage) { search->wait(-1); auto refCount = unreference(search, true); DEBUG_BREAK_IF(refCount != 1u); - ((void)(refCount)); + UNUSED_VARIABLE(refCount); } delete handleStorage.fragmentStorageData[i].osHandleStorage; handleStorage.fragmentStorageData[i].osHandleStorage = nullptr; diff --git a/runtime/utilities/tag_allocator.h b/runtime/utilities/tag_allocator.h index 566e384d26..9a5b6d4a7e 100644 --- a/runtime/utilities/tag_allocator.h +++ b/runtime/utilities/tag_allocator.h @@ -118,7 +118,7 @@ class TagAllocator { MOCKABLE_VIRTUAL void returnTagToFreePool(NodeType *node) { NodeType *usedNode = usedTags.removeOne(*node).release(); DEBUG_BREAK_IF(usedNode == nullptr); - ((void)(usedNode)); + UNUSED_VARIABLE(usedNode); freeTags.pushFrontOne(*node); } @@ -152,7 +152,7 @@ class TagAllocator { Start += tagSize; } DEBUG_BREAK_IF(Start > End); - ((void)(End)); + UNUSED_VARIABLE(End); tagPoolMemory.push_back(nodesMemory); }