Skip to content

Commit 60d1f26

Browse files
Addressed Very high Coverity issue
Ensured that `create_property_list` always returns an not-null unique pointer by creating an default-constructed property_list for the fall-through. With this change we no longer need to branches for call to sycl::queue constructor, since propList is always available.
1 parent 8eab04b commit 60d1f26

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

libsyclinterface/source/dpctl_sycl_queue_interface.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool set_kernel_arg(handler &cgh,
121121
return arg_set;
122122
}
123123

124-
std::unique_ptr<property_list> create_property_list(int properties)
124+
static std::unique_ptr<property_list> create_property_list(int properties)
125125
{
126126
std::unique_ptr<property_list> propList;
127127
int _prop = properties;
@@ -143,6 +143,9 @@ std::unique_ptr<property_list> create_property_list(int properties)
143143
propList =
144144
std::make_unique<property_list>(sycl::property::queue::in_order());
145145
}
146+
else {
147+
propList = std::make_unique<property_list>();
148+
}
146149

147150
if (_prop) {
148151
std::stringstream ss;
@@ -185,7 +188,7 @@ DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef,
185188
}
186189
auto propList = create_property_list(properties);
187190

188-
if (propList && handler) {
191+
if (handler) {
189192
try {
190193
auto Queue = new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler),
191194
*propList);
@@ -194,26 +197,9 @@ DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef,
194197
error_handler(e, __FILE__, __func__, __LINE__);
195198
}
196199
}
197-
else if (properties) {
198-
try {
199-
auto Queue = new queue(*ctx, *dev, *propList);
200-
q = wrap<queue>(Queue);
201-
} catch (std::exception const &e) {
202-
error_handler(e, __FILE__, __func__, __LINE__);
203-
}
204-
}
205-
else if (handler) {
206-
try {
207-
auto Queue =
208-
new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler));
209-
q = wrap<queue>(Queue);
210-
} catch (std::exception const &e) {
211-
error_handler(e, __FILE__, __func__, __LINE__);
212-
}
213-
}
214200
else {
215201
try {
216-
auto Queue = new queue(*ctx, *dev);
202+
auto Queue = new queue(*ctx, *dev, *propList);
217203
q = wrap<queue>(Queue);
218204
} catch (std::exception const &e) {
219205
error_handler(e, __FILE__, __func__, __LINE__);

0 commit comments

Comments
 (0)