Skip to content

Commit ab151e9

Browse files
authored
Merge pull request #1618 from PietroGhg/pietro/coverity_reqd
[NATIVECPU] Fix coverity warnings when handling reqd_work_group_size
2 parents dcbad34 + 5f9e6c5 commit ab151e9

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

source/adapters/native_cpu/program.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "common/ur_util.hpp"
1515
#include "program.hpp"
1616
#include <cstdint>
17+
#include <memory>
1718

1819
UR_APIEXPORT ur_result_t UR_APICALL
1920
urProgramCreateWithIL(ur_context_handle_t hContext, const void *pIL,
@@ -63,11 +64,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
6364
UR_ASSERT(phProgram, UR_RESULT_ERROR_INVALID_NULL_POINTER);
6465
UR_ASSERT(pBinary != nullptr, UR_RESULT_ERROR_INVALID_NULL_POINTER);
6566

66-
auto hProgram = new ur_program_handle_t_(
67+
auto hProgram = std::make_unique<ur_program_handle_t_>(
6768
hContext, reinterpret_cast<const unsigned char *>(pBinary));
6869
if (pProperties != nullptr) {
6970
for (uint32_t i = 0; i < pProperties->count; i++) {
70-
auto mdNode = pProperties->pMetadatas[i];
71+
const auto &mdNode = pProperties->pMetadatas[i];
7172
std::string mdName(mdNode.pName);
7273
auto [Prefix, Tag] = splitMetadataName(mdName);
7374
if (Tag == __SYCL_UR_PROGRAM_METADATA_TAG_REQD_WORK_GROUP_SIZE) {
@@ -89,7 +90,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
8990
nativecpu_it++;
9091
}
9192

92-
*phProgram = hProgram;
93+
*phProgram = hProgram.release();
9394

9495
return UR_RESULT_SUCCESS;
9596
}

source/adapters/native_cpu/program.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <ur_api.h>
1414

1515
#include "context.hpp"
16+
17+
#include <array>
1618
#include <map>
1719

1820
namespace native_cpu {

0 commit comments

Comments
 (0)