From 5baf5919c2d4bd8b1c2d38ddabb76377b7016cf0 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Tue, 1 Jun 2021 08:11:15 -0500 Subject: [PATCH] Follow DPCTLDevice_CreateFromSelector which passes the check --- dpctl-capi/source/dpctl_sycl_platform_interface.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dpctl-capi/source/dpctl_sycl_platform_interface.cpp b/dpctl-capi/source/dpctl_sycl_platform_interface.cpp index ac8a1a1c3c..56e3fd4a50 100644 --- a/dpctl-capi/source/dpctl_sycl_platform_interface.cpp +++ b/dpctl-capi/source/dpctl_sycl_platform_interface.cpp @@ -76,13 +76,12 @@ __dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_Create() __dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_CreateFromSelector( __dpctl_keep const DPCTLSyclDeviceSelectorRef DSRef) { - DPCTLSyclPlatformRef PRef = nullptr; - auto DS = unwrap(DSRef); - if (DS) { + if (DSRef) { + auto DS = unwrap(DSRef); platform *P = nullptr; try { P = new platform(*DS); - PRef = wrap(P); + return wrap(P); } catch (std::bad_alloc const &ba) { std::cerr << ba.what() << '\n'; return nullptr; @@ -96,7 +95,7 @@ __dpctl_give DPCTLSyclPlatformRef DPCTLPlatform_CreateFromSelector( std::cerr << "Device selector pointer cannot be NULL\n"; } - return PRef; + return nullptr; } void DPCTLPlatform_Delete(__dpctl_take DPCTLSyclPlatformRef PRef)