Skip to content

Commit 297e54d

Browse files
[SYCL][NFC] Add initializers to local variables (#7350)
This patch aims to improve situation with unit-tests: a lot of PI routines only have dummy mock versions of them. Dummy mocks ignore all arguments, leaving out-parameters untouched. Depending on how they used at call site, this could lead to some obscure errors like `bad_alloc` if an uninitialized value was used to set a size of a `vector`. Discovered while working on a unit-test in #7333
1 parent 3a4e797 commit 297e54d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sycl/source/detail/kernel_info.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ template <typename Param>
4747
typename std::enable_if<
4848
std::is_same<typename Param::return_type, uint32_t>::value, uint32_t>::type
4949
get_kernel_info(RT::PiKernel Kernel, const plugin &Plugin) {
50-
uint32_t Result;
50+
uint32_t Result = 0;
5151

5252
// TODO catch an exception and put it to list of asynchronous exceptions
5353
Plugin.call<PiApiKind::piKernelGetInfo>(Kernel, PiInfoCode<Param>::value,
@@ -83,7 +83,7 @@ get_kernel_device_specific_info(RT::PiKernel Kernel, RT::PiDevice Device,
8383
const plugin &Plugin) {
8484
static_assert(is_kernel_device_specific_info_desc<Param>::value,
8585
"Unexpected kernel_device_specific information descriptor");
86-
typename Param::return_type Result;
86+
typename Param::return_type Result = {};
8787
// TODO catch an exception and put it to list of asynchronous exceptions
8888
get_kernel_device_specific_info_helper<Param>(
8989
Kernel, Device, Plugin, &Result, sizeof(typename Param::return_type));
@@ -98,7 +98,7 @@ get_kernel_device_specific_info(RT::PiKernel Kernel, RT::PiDevice Device,
9898
const plugin &Plugin) {
9999
static_assert(is_kernel_device_specific_info_desc<Param>::value,
100100
"Unexpected kernel_device_specific information descriptor");
101-
size_t Result[3];
101+
size_t Result[3] = {0, 0, 0};
102102
// TODO catch an exception and put it to list of asynchronous exceptions
103103
get_kernel_device_specific_info_helper<Param>(Kernel, Device, Plugin, Result,
104104
sizeof(size_t) * 3);
@@ -121,7 +121,7 @@ uint32_t get_kernel_device_specific_info_with_input(RT::PiKernel Kernel,
121121
"Unexpected kernel_device_specific information descriptor for "
122122
"query with input");
123123
size_t Input[3] = {In[0], In[1], In[2]};
124-
uint32_t Result;
124+
uint32_t Result = 0;
125125
// TODO catch an exception and put it to list of asynchronous exceptions
126126
Plugin.call<PiApiKind::piKernelGetSubGroupInfo>(
127127
Kernel, Device, PiInfoCode<Param>::value, sizeof(size_t) * 3, Input,

0 commit comments

Comments
 (0)