SWDEV-306939 - Fix vdi errors/warnings by CppCheck

Change-Id: I56d910f8363787f1050d5d7e8064ed553c5827fd
Bu işleme şunda yer alıyor:
Satyanvesh Dittakavi committed 2022-01-12 00:22:16 -05:00
1 ebeveyn 8b5b2a2d79
işleme e20dd61932
45 files changed
+113 -160

No files matched your search

+1 -1
Dosyayı Görüntüle
@@ -249,7 +249,7 @@ void GpuDebugManager::wavefrontControl(uint32_t waveAction, uint32_t waveMode, u
}
void GpuDebugManager::setAddressWatch(uint32_t numWatchPoints, void** watchAddress,
uint64_t* watchMask, uint64_t* watchMode, DebugEvent* event) {
uint64_t* watchMask, uint64_t* watchMode, DebugEvent* pEvent) {
size_t requiredSize = numWatchPoints * sizeof(HwDbgAddressWatch);
// previously allocated size is not big enough, allocate new memory
+8 -17
Dosyayı Görüntüle
@@ -709,10 +709,9 @@ Device::XferBuffers::~XferBuffers() {
}
bool Device::XferBuffers::create() {
Memory* xferBuf = NULL;
bool result = false;
// Create a buffer object
xferBuf = new Memory(dev(), bufSize_);
Memory* xferBuf = new Memory(dev(), bufSize_);
// Try to allocate memory for the transfer buffer
if ((NULL == xferBuf) || !xferBuf->create(type_)) {
@@ -1150,11 +1149,11 @@ bool Device::initializeHeapResources() {
device::VirtualDevice* Device::createVirtualDevice(amd::CommandQueue* queue) {
bool profiling = false;
bool interopQueue = false;
uint rtCUs = amd::CommandQueue::RealTimeDisabled;
uint deviceQueueSize = 0;
if (queue != NULL) {
bool interopQueue = false;
profiling = queue->properties().test(CL_QUEUE_PROFILING_ENABLE);
if (queue->asHostQueue() != NULL) {
interopQueue = (0 != (queue->context().info().flags_ &
@@ -1196,11 +1195,10 @@ typedef std::unordered_map<int, bool> requestedDevices_t;
//! Parses the requested list of devices to be exposed to the user.
static void parseRequestedDeviceList(requestedDevices_t& requestedDevices) {
char* pch = NULL;
int requestedDeviceCount = 0;
const char* requestedDeviceList = GPU_DEVICE_ORDINAL;
pch = strtok(const_cast<char*>(requestedDeviceList), ",");
char* pch = strtok(const_cast<char*>(requestedDeviceList), ",");
while (pch != NULL) {
bool deviceIdValid = true;
int currentDeviceIndex = atoi(pch);
@@ -1318,10 +1316,9 @@ amd::Image::Format Device::getOclFormat(const CalFormat& format) const {
// Create buffer without an owner (merge common code with createBuffer() ?)
gpu::Memory* Device::createScratchBuffer(size_t size) const {
Memory* gpuMemory = NULL;
// Create a memory object
gpuMemory = new gpu::Memory(*this, size);
Memory* gpuMemory = new gpu::Memory(*this, size);
if (NULL == gpuMemory || !gpuMemory->create(Resource::Local)) {
delete gpuMemory;
gpuMemory = NULL;
@@ -1501,7 +1498,6 @@ gpu::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const {
}
gpu::Memory* Device::createImage(amd::Memory& owner, bool directAccess) const {
size_t size = owner.getSize();
amd::Image& image = *owner.asImage();
gpu::Memory* gpuImage = NULL;
CalFormat format = getCalFormat(image.getImageFormat());
@@ -1645,19 +1641,16 @@ bool Device::createSampler(const amd::Sampler& owner, device::Sampler** sampler)
}
device::Memory* Device::createView(amd::Memory& owner, const device::Memory& parent) const {
size_t size = owner.getSize();
assert((owner.asImage() != NULL) && "View supports images only");
const amd::Image& image = *owner.asImage();
gpu::Memory* gpuImage = NULL;
CalFormat format = getCalFormat(image.getImageFormat());
gpuImage =
gpu::Memory* gpuImage =
new gpu::Image(*this, owner, image.getWidth(), image.getHeight(), image.getDepth(),
format.type_, format.channelOrder_, image.getType(), image.getMipLevels());
// Create resource
if (NULL != gpuImage) {
bool result = false;
Resource::ImageViewParams params;
const gpu::Memory& gpuMem = static_cast<const gpu::Memory&>(parent);
@@ -1669,7 +1662,7 @@ device::Memory* Device::createView(amd::Memory& owner, const device::Memory& par
params.memory_ = &gpuMem;
// Create memory object
result = gpuImage->create(Resource::ImageView, &params);
bool result = gpuImage->create(Resource::ImageView, &params);
if (!result) {
delete gpuImage;
return NULL;
@@ -2136,8 +2129,7 @@ void Device::svmFree(void* ptr) const {
if (isFineGrainedSystem()) {
amd::Os::alignedFree(ptr);
} else {
amd::Memory* svmMem = NULL;
svmMem = amd::MemObjMap::FindMemObj(ptr);
amd::Memory* svmMem = amd::MemObjMap::FindMemObj(ptr);
if (NULL != svmMem) {
svmMem->release();
amd::MemObjMap::RemoveMemObj(ptr);
@@ -2258,12 +2250,11 @@ int32_t Device::hwDebugManagerInit(amd::Context* context, uintptr_t messageStora
}
bool Device::SetClockMode(const cl_set_device_clock_mode_input_amd setClockModeInput, cl_set_device_clock_mode_output_amd* pSetClockModeOutput) {
bool result = true;
static const bool bValidate = true;
PerformAdapterInitialization(bValidate);
GSLClockModeInfo clockModeInfo = {};
clockModeInfo.clockmode = static_cast<GSLClockMode>(setClockModeInput.clock_mode);
result = gslSetClockMode(&clockModeInfo);
bool result = gslSetClockMode(&clockModeInfo);
CloseInitializedAdapter(bValidate);
return result;
}
+2 -4
Dosyayı Görüntüle
@@ -819,7 +819,6 @@ void* Memory::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& reg
if (memory == NULL) {
// for map target of svm buffer , we need use svm host ptr
memory = new (dev().context()) amd::Buffer(dev().context(), flag, owner()->getSize());
Memory* gpuMemory;
do {
if ((memory == NULL) || !memory->create(initHostPtr, SysMem)) {
@@ -828,7 +827,7 @@ void* Memory::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& reg
}
memory->setCacheStatus(canBeCached);
gpuMemory = reinterpret_cast<Memory*>(memory->getDeviceMemory(dev()));
Memory* gpuMemory = reinterpret_cast<Memory*>(memory->getDeviceMemory(dev()));
// Create, Map and get the base pointer for the resource
if ((gpuMemory == NULL) || (NULL == gpuMemory->map(NULL))) {
@@ -1082,14 +1081,13 @@ void* Image::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& regi
amd::Buffer(dev().context(), 0, cal()->width_ * height * depth * elementSize());
memory->setVirtualDevice(owner()->getVirtualDevice());
Memory* gpuMemory;
do {
if ((memory == NULL) || !memory->create(NULL, SysMem)) {
failed = true;
break;
}
gpuMemory = reinterpret_cast<Memory*>(memory->getDeviceMemory(dev()));
Memory* gpuMemory = reinterpret_cast<Memory*>(memory->getDeviceMemory(dev()));
// Create, Map and get the base pointer for the resource
if ((gpuMemory == NULL) || (NULL == gpuMemory->map(NULL))) {
+1 -2
Dosyayı Görüntüle
@@ -405,7 +405,6 @@ void PrintfDbg::outputDbgBuffer(const device::PrintfInfo& info, const uint32_t*
if (posStart != std::string::npos) {
bool printFloat = false;
int vectorSize = 0;
size_t length;
size_t idPos = 0;
// Search for PrintfDbg specifier in the format string.
@@ -442,7 +441,7 @@ void PrintfDbg::outputDbgBuffer(const device::PrintfInfo& info, const uint32_t*
// Is it a scalar value?
if (vectorSize == 0) {
length = outputArgument(fmt, printFloat, info.arguments_[j], &s[i]);
size_t length = outputArgument(fmt, printFloat, info.arguments_[j], &s[i]);
if (0 == length) {
return;
}
+2 -5
Dosyayı Görüntüle
@@ -241,12 +241,11 @@ bool NullProgram::linkImpl(amd::option::Options* options) {
if ((dbgSize > 0) && options->isDumpFlagSet(amd::option::DUMP_DEBUGIL)) {
std::string debugilWithLine;
size_t b = 1;
size_t e;
int linenum = 0;
char cstr[9];
cstr[8] = 0;
while (b != std::string::npos) {
e = debugILStr.find_first_of("\n", b);
size_t e = debugILStr.find_first_of("\n", b);
if (e != std::string::npos) {
++e;
}
@@ -582,12 +581,11 @@ bool NullProgram::linkImpl(const std::vector<device::Program*>& inputPrograms,
if ((dbgSize > 0) && options->isDumpFlagSet(amd::option::DUMP_DEBUGIL)) {
std::string debugilWithLine;
size_t b = 1;
size_t e;
int linenum = 0;
char cstr[9];
cstr[8] = 0;
while (b != std::string::npos) {
e = debugILStr.find_first_of("\n", b);
size_t e = debugILStr.find_first_of("\n", b);
if (e != std::string::npos) {
++e;
}
@@ -1978,7 +1976,6 @@ bool ORCAHSALoaderContext::GpuMemCopy(void* dst, size_t offset, const void* src,
gpu::Memory* mem = reinterpret_cast<gpu::Memory*>(dst);
return program_->gpuDevice().xferMgr().writeBuffer(src, *mem, amd::Coord3D(offset), amd::Coord3D(size),
true);
return true;
}
void ORCAHSALoaderContext::GpuMemFree(void* ptr, size_t size) {
+1 -1
Dosyayı Görüntüle
@@ -1149,7 +1149,7 @@ void Resource::wait(VirtualGPU& gpu, bool waitOnBusyEngine) const {
// Check if we have to wait unconditionally
if (!waitOnBusyEngine ||
// or we have to wait only if another engine was used on this resource
(waitOnBusyEngine && (gpuEvent->engineId_ != gpu.engineID_))) {
(gpuEvent->engineId_ != gpu.engineID_)) {
gpu.waitForEvent(gpuEvent);
}
+5 -8
Dosyayı Görüntüle
@@ -120,13 +120,13 @@ void VirtualGPU::MemoryDependency::validate(VirtualGPU& gpu, const Memory* memor
void VirtualGPU::MemoryDependency::clear(bool all) {
if (numMemObjectsInQueue_ > 0) {
size_t i, j;
if (all) {
endMemObjectsInQueue_ = numMemObjectsInQueue_;
}
// If the current launch didn't start from the beginning, then move the data
if (0 != endMemObjectsInQueue_) {
size_t i, j;
// Preserve all objects from the current kernel
for (i = 0, j = endMemObjectsInQueue_; j < numMemObjectsInQueue_; i++, j++) {
memObjectsInQueue_[i].start_ = memObjectsInQueue_[j].start_;
@@ -1096,7 +1096,6 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) {
vcmd.setStatus(CL_MAP_FAILURE);
}
} else if ((vcmd.memory().getType() == CL_MEM_OBJECT_IMAGE1D_BUFFER)) {
amd::Memory* bufferFromImage = NULL;
Memory* memoryBuf = memory;
amd::Coord3D origin(vcmd.origin()[0]);
amd::Coord3D size(vcmd.size()[0]);
@@ -1104,7 +1103,7 @@ void VirtualGPU::submitMapMemory(amd::MapMemoryCommand& vcmd) {
origin.c[0] *= elemSize;
size.c[0] *= elemSize;
bufferFromImage = createBufferFromImage(vcmd.memory());
amd::Memory* bufferFromImage = createBufferFromImage(vcmd.memory());
if (NULL == bufferFromImage) {
LogError("We should not fail buffer creation from image_buffer!");
} else {
@@ -1195,7 +1194,6 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
vcmd.setStatus(CL_OUT_OF_RESOURCES);
}
} else if ((vcmd.memory().getType() == CL_MEM_OBJECT_IMAGE1D_BUFFER)) {
amd::Memory* bufferFromImage = NULL;
Memory* memoryBuf = memory;
amd::Coord3D origin(writeMapInfo->origin_[0]);
amd::Coord3D size(writeMapInfo->region_[0]);
@@ -1203,7 +1201,7 @@ void VirtualGPU::submitUnmapMemory(amd::UnmapMemoryCommand& vcmd) {
origin.c[0] *= elemSize;
size.c[0] *= elemSize;
bufferFromImage = createBufferFromImage(vcmd.memory());
amd::Memory* bufferFromImage = createBufferFromImage(vcmd.memory());
if (NULL == bufferFromImage) {
LogError("We should not fail buffer creation from image_buffer!");
} else {
@@ -3071,7 +3069,6 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
const amd::KernelParameterDescriptor& desc = signature.at(i);
const HSAILKernel::Argument* arg = hsaKernel.argument(i);
Memory* gpuMem = nullptr;
bool readOnly = false;
amd::Memory* mem = nullptr;
// Find if current argument is a buffer
@@ -3098,6 +3095,7 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
memoryDependency().clear(!All);
continue;
} else if (gpuMem != nullptr) {
bool readOnly = false;
// Check image
readOnly = (desc.accessQualifier_ == CL_KERNEL_ARG_ACCESS_READ_ONLY) ? true : false;
// Check buffer
@@ -3156,8 +3154,7 @@ void VirtualGPU::buildKernelInfo(const HSAILKernel& hsaKernel, hsa_kernel_dispat
kernelInfo.scratchBufferSizeInBytes = scratchBuf->size();
// Get the address of the scratch buffer and its size for CPU access
address scratchRingAddr = NULL;
scratchRingAddr = static_cast<address>(scratchBuf->map(NULL, 0));
address scratchRingAddr = static_cast<address>(scratchBuf->map(NULL, 0));
dbgManager->setScratchRing(scratchRingAddr, scratchBuf->size());
scratchBuf->unmap(NULL);
} else {
+2 -2
Dosyayı Görüntüle
@@ -363,11 +363,11 @@ CALGSLContext::copyPartial(GpuEvent& event,
uint32 mode = GSL_SYNCUPLOAD_IGNORE_ELEMENTSIZE;
EngineType engineId = MainEngine;
assert(m_cs != 0);
CopyType type = USE_NONE;
uint64 linearBytePitch = 0;
intp bpp = 0;
type = dev()->GetCopyType(srcMem, destMem, srcOffset, destOffset, m_allowDMA, flags, size[0], enableRectCopy);
CopyType type = dev()->GetCopyType(srcMem, destMem, srcOffset, destOffset, m_allowDMA,
flags, size[0], enableRectCopy);
if(type == USE_NONE)
{
+1 -1
Dosyayı Görüntüle
@@ -75,7 +75,7 @@ public:
}
bool copyPartial(GpuEvent& event, gslMemObject srcMem, size_t* srcOffset,
gslMemObject destMem, size_t* destOffset, size_t* size, CALmemcopyflags flags, bool enableCopyRect, uint32 bytesPerElement);
gslMemObject destMem, size_t* destOffset, size_t* size, CALmemcopyflags flags, bool enableRectCopy, uint32 bytesPerElement);
void setSamplerParameter(uint32 sampler, gslTexParameterPname param, CALvoid* vals);
+6 -6
Dosyayı Görüntüle
@@ -265,7 +265,7 @@ static uint32 parse4TupleValues(const char* element, uint32*& values)
return numTuples;
}
void
static void
CALGSLDevice::parsePowerParam(const char* element, gslRuntimeConfigUint32Value& pwrCount, gslRuntimeConfigUint32pValue& pwrPointer)
{
uint32 count = 0;
@@ -843,7 +843,7 @@ Wait(gsl::gsCtx* cs, gslQueryTarget target, gslQueryObject object)
assert(param == 1);
}
bool
static bool
CALGSLDevice::ResolveAperture(const gslMemObjectAttribTiling tiling) const
{
// Don't ask for aperture if the tiling is linear.
@@ -1163,7 +1163,7 @@ CALGSLDevice::resMapLocal(size_t& pitch,
else
{
// Allocate map structure for the unmap call
GSLDeviceMemMap* memMap = (GSLDeviceMemMap*)malloc(sizeof(GSLDeviceMemMap));
GSLDeviceMemMap* memMap = static_cast<GSLDeviceMemMap*>(malloc(sizeof(GSLDeviceMemMap)));
if (memMap == NULL)
{
@@ -1270,7 +1270,7 @@ CALGSLDevice::resUnmapLocal(gslMemObject mem)
return;
}
GSLDeviceMemMap* memMap = (GSLDeviceMemMap*)iter->second;
GSLDeviceMemMap* memMap = static_cast<GSLDeviceMemMap*>(iter->second);
m_hack.erase(iter);
memMap->mem->unmap(m_cs);
@@ -1500,7 +1500,7 @@ CALGSLDevice::calcScratchBufferSize(uint32 regNum) const
return scratchBufferSizes[target];
}
void
static void
CALGSLDevice::convertInputChannelOrder(intp*channelOrder) const
{
// set default to indicate that we don't want to override the channel order.
@@ -1659,4 +1659,4 @@ CALGSLDevice::gslSetClockMode(GSLClockModeInfo * clockModeInfo)
result = true;
}
return result;
}
}
+4 -4
Dosyayı Görüntüle
@@ -88,12 +88,12 @@ public:
void close();
gslMemObject resAlloc(const CALresourceDesc* desc) const;
void* resMapLocal(size_t& pitch, gslMemObject res, gslMapAccessType flags);
void resUnmapLocal(gslMemObject res);
void* resMapLocal(size_t& pitch, gslMemObject mem, gslMapAccessType flags);
void resUnmapLocal(gslMemObject mem);
void resFree(gslMemObject mem) const;
void* resMapRemote(size_t& pitch, gslMemObject res, gslMapAccessType flags) const;
void resUnmapRemote(gslMemObject res) const;
void* resMapRemote(size_t& pitch, gslMemObject mem, gslMapAccessType flags) const;
void resUnmapRemote(gslMemObject mem) const;
gslMemObject resGetHeap(size_t size) const;
gslMemObject resAllocView(gslMemObject res, gslResource3D size,
+1 -1
Dosyayı Görüntüle
@@ -69,7 +69,7 @@ CALGSLDevice::associateD3D9Device(void* d3d9Device)
#else // !ATI_OS_WIN
bool
CALGSLDevice::associateD3D9Device(void* d3dDevice)
CALGSLDevice::associateD3D9Device(void* d3d9Device)
{
return false;
}
+5 -5
Dosyayı Görüntüle
@@ -182,7 +182,7 @@ IniSection::IniSection()
IniSection::IniSection(const IniSection& s)
{
name = s.name;
for(EntryDBIterator iter = s.entryDB.begin() ; iter != s.entryDB.end(); iter++)
for(EntryDBIterator iter = s.entryDB.begin() ; iter != s.entryDB.end(); ++iter)
{
entryDB[iter->first] = iter->second;
}
@@ -196,7 +196,7 @@ IniSection::IniSection(cmString n)
IniSection::~IniSection()
{
for(EntryDBIterator iter = entryDB.begin() ; iter != entryDB.end(); iter++)
for(EntryDBIterator iter = entryDB.begin() ; iter != entryDB.end(); ++iter)
{
delete iter->second;
}
@@ -267,7 +267,7 @@ IniFile::~IniFile()
sectionDB.clear();
}
const cmString IniSection::getName()
const cmString IniSection::getName () const
{
return name;
}
@@ -376,7 +376,7 @@ void IniValueFloat::printAST()
void IniSection::printAST()
{
for(EntryDBIterator iter = entryDB.begin() ; iter != entryDB.end(); iter++)
for(EntryDBIterator iter = entryDB.begin() ; iter != entryDB.end(); ++iter)
{
cmString name = iter->first;
IniValue *v = iter->second;
@@ -389,7 +389,7 @@ void IniSection::printAST()
void IniFile::printAST()
{
for(SectionDBIterator iter = sectionDB.begin() ; iter != sectionDB.end(); iter++)
for(SectionDBIterator iter = sectionDB.begin() ; iter != sectionDB.end(); ++iter)
{
IniSection* s = iter->second;
std::cerr << "[" << s->getName().c_str() << "]\n";
+2 -2
Dosyayı Görüntüle
@@ -158,7 +158,7 @@ public:
bool is_float;
};
int cmp_nocase(const std::string s1, const std::string s2)
int cmp_nocase(const std::string& s1, const std::string& s2)
{
std::string::const_iterator p1 = s1.begin();
std::string::const_iterator p2 = s2.begin();
@@ -175,7 +175,7 @@ int cmp_nocase(const std::string s1, const std::string s2)
return static_cast<int>(s2.size()-s1.size());
}
IniValue* IniFileParser::parseValue(std::string value ) {
IniValue* IniFileParser::parseValue(std::string& value ) {
std::string trimmed = trim(value);
std::stringstream ss(trimmed);