Skip to content

Commit

Permalink
[SYCL] Fix minor Coverity issues with uninitialized variables (#15625)
Browse files Browse the repository at this point in the history
This PR fixes Coverity hits due to potential use of uninitialized
variables.
  • Loading branch information
uditagarwal97 authored Oct 10, 2024
1 parent 9073865 commit 9cd5a3b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
16 changes: 8 additions & 8 deletions sycl/source/detail/bindless_images.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ alloc_image_mem(const image_descriptor &desc, const sycl::device &syclDevice,
ur_image_format_t urFormat;
populate_ur_structs(desc, urDesc, urFormat);

image_mem_handle retHandle;
image_mem_handle retHandle = {};

// Call impl.
Adapter->call<sycl::errc::memory_allocation,
Expand Down Expand Up @@ -201,7 +201,7 @@ __SYCL_EXPORT image_mem_handle get_mip_level_mem_handle(
const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter();

// Call impl.
image_mem_handle individual_image;
image_mem_handle individual_image = {};
Adapter->call<sycl::errc::runtime,
sycl::detail::UrApiKind::urBindlessImagesMipmapGetLevelExp>(
C, Device, mipMem.raw_handle, level, &individual_image.raw_handle);
Expand Down Expand Up @@ -284,7 +284,7 @@ create_image(image_mem_handle memHandle, const image_descriptor &desc,
populate_ur_structs(desc, urDesc, urFormat);

// Call impl.
ur_exp_image_mem_native_handle_t urImageHandle;
ur_exp_image_mem_native_handle_t urImageHandle = 0;
Adapter
->call<sycl::errc::runtime,
sycl::detail::UrApiKind::urBindlessImagesUnsampledImageCreateExp>(
Expand Down Expand Up @@ -421,7 +421,7 @@ create_image(void *devPtr, size_t pitch, const bindless_image_sampler &sampler,
populate_ur_structs(desc, urDesc, urFormat, pitch);

// Call impl.
ur_exp_image_mem_native_handle_t urImageHandle;
ur_exp_image_mem_native_handle_t urImageHandle = 0;
Adapter->call<sycl::errc::runtime,
sycl::detail::UrApiKind::urBindlessImagesSampledImageCreateExp>(
C, Device, reinterpret_cast<ur_exp_image_mem_native_handle_t>(devPtr),
Expand Down Expand Up @@ -550,7 +550,7 @@ image_mem_handle map_external_image_memory(external_mem extMem,

ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle};

image_mem_handle retHandle;
image_mem_handle retHandle = {};
Adapter->call<sycl::errc::invalid,
sycl::detail::UrApiKind::urBindlessImagesMapExternalArrayExp>(
C, Device, &urFormat, &urDesc, urExternalMem, &retHandle.raw_handle);
Expand Down Expand Up @@ -580,7 +580,7 @@ void *map_external_linear_memory(external_mem extMem, uint64_t offset,

ur_exp_external_mem_handle_t urExternalMem{extMem.raw_handle};

void *retMemory;
void *retMemory = nullptr;
Adapter->call<
sycl::errc::invalid,
sycl::detail::UrApiKind::urBindlessImagesMapExternalLinearMemoryExp>(
Expand Down Expand Up @@ -631,7 +631,7 @@ __SYCL_EXPORT external_semaphore import_external_semaphore(
sycl::detail::getSyclObjImpl(syclDevice);
ur_device_handle_t Device = DevImpl->getHandleRef();

ur_exp_external_semaphore_handle_t urExternalSemaphore;
ur_exp_external_semaphore_handle_t urExternalSemaphore = nullptr;
ur_exp_file_descriptor_t urFileDescriptor = {};
urFileDescriptor.stype = UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR;
urFileDescriptor.fd = externalSemaphoreDesc.external_resource.file_descriptor;
Expand Down Expand Up @@ -778,7 +778,7 @@ get_image_channel_type(const image_mem_handle memHandle,
sycl::detail::getSyclObjImpl(syclContext);
const sycl::detail::AdapterPtr &Adapter = CtxImpl->getAdapter();

ur_image_format_t URFormat;
ur_image_format_t URFormat = {};

Adapter->call<sycl::errc::invalid,
sycl::detail::UrApiKind::urBindlessImagesImageGetInfoExp>(
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ bool device::ext_oneapi_can_access_peer(const device &peer,
return true;
}

size_t returnSize;
int value;
size_t returnSize = 0;
int value = 0;

ur_exp_peer_info_t UrAttr = [&]() {
switch (attr) {
Expand Down
7 changes: 6 additions & 1 deletion sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,12 @@ handler::getCommandGraph() const {
if (impl->MGraph) {
return impl->MGraph;
}
return MQueue->getCommandGraph();

if (this->MQueue)
return MQueue->getCommandGraph();
// We should never reach here. MGraph and MQueue can not be null
// simultaneously.
return nullptr;
}

void handler::setUserFacingNodeType(ext::oneapi::experimental::node_type Type) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/virtual_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ __SYCL_EXPORT size_t get_mem_granularity(const device &SyclDevice,
sycl::detail::getSyclObjImpl(SyclContext);
const sycl::detail::AdapterPtr &Adapter = ContextImpl->getAdapter();
#ifndef NDEBUG
size_t InfoOutputSize;
size_t InfoOutputSize = 0;
Adapter->call<sycl::detail::UrApiKind::urVirtualMemGranularityGetInfo>(
ContextImpl->getHandleRef(), DeviceImpl->getHandleRef(), GranularityQuery,
0, nullptr, &InfoOutputSize);
Expand Down
2 changes: 1 addition & 1 deletion xpti/include/xpti/xpti_data_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ struct payload_t {
/// Kernel/lambda/function address
const void *code_ptr_va = nullptr;
/// Internal bookkeeping slot - do not change.
uint64_t internal;
uint64_t internal = 0;
/// Flags indicating whether string name, codepointer, source file and hash
/// values are available
uint64_t flags = 0;
Expand Down

0 comments on commit 9cd5a3b

Please sign in to comment.