From 60d1f26c836b1301e792bbaaf15989e1eb779832 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Fri, 25 Aug 2023 09:17:35 -0500 Subject: [PATCH 1/2] 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. --- .../source/dpctl_sycl_queue_interface.cpp | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/libsyclinterface/source/dpctl_sycl_queue_interface.cpp b/libsyclinterface/source/dpctl_sycl_queue_interface.cpp index 387374a032..703f58cb7b 100644 --- a/libsyclinterface/source/dpctl_sycl_queue_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_queue_interface.cpp @@ -121,7 +121,7 @@ bool set_kernel_arg(handler &cgh, return arg_set; } -std::unique_ptr create_property_list(int properties) +static std::unique_ptr create_property_list(int properties) { std::unique_ptr propList; int _prop = properties; @@ -143,6 +143,9 @@ std::unique_ptr create_property_list(int properties) propList = std::make_unique(sycl::property::queue::in_order()); } + else { + propList = std::make_unique(); + } if (_prop) { std::stringstream ss; @@ -185,7 +188,7 @@ DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef, } auto propList = create_property_list(properties); - if (propList && handler) { + if (handler) { try { auto Queue = new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler), *propList); @@ -194,26 +197,9 @@ DPCTLQueue_Create(__dpctl_keep const DPCTLSyclContextRef CRef, error_handler(e, __FILE__, __func__, __LINE__); } } - else if (properties) { - try { - auto Queue = new queue(*ctx, *dev, *propList); - q = wrap(Queue); - } catch (std::exception const &e) { - error_handler(e, __FILE__, __func__, __LINE__); - } - } - else if (handler) { - try { - auto Queue = - new queue(*ctx, *dev, DPCTL_AsyncErrorHandler(handler)); - q = wrap(Queue); - } catch (std::exception const &e) { - error_handler(e, __FILE__, __func__, __LINE__); - } - } else { try { - auto Queue = new queue(*ctx, *dev); + auto Queue = new queue(*ctx, *dev, *propList); q = wrap(Queue); } catch (std::exception const &e) { error_handler(e, __FILE__, __func__, __LINE__); From dd6a01473a9355a39384d6a3f41003c1aa378ff2 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Mon, 28 Aug 2023 12:38:27 -0500 Subject: [PATCH 2/2] Update libsyclinterface/source/dpctl_sycl_queue_interface.cpp Remove unneeded static keyword in definition of create_property_list function in anonymous namespace --- libsyclinterface/source/dpctl_sycl_queue_interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsyclinterface/source/dpctl_sycl_queue_interface.cpp b/libsyclinterface/source/dpctl_sycl_queue_interface.cpp index 703f58cb7b..ce318ce37e 100644 --- a/libsyclinterface/source/dpctl_sycl_queue_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_queue_interface.cpp @@ -121,7 +121,7 @@ bool set_kernel_arg(handler &cgh, return arg_set; } -static std::unique_ptr create_property_list(int properties) +std::unique_ptr create_property_list(int properties) { std::unique_ptr propList; int _prop = properties;