Skip to content

Commit 9c1dfc3

Browse files
Add nullptr Value check to Fill128 C-API
1 parent 530b692 commit 9c1dfc3

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

libsyclinterface/source/dpctl_sycl_queue_interface.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ DPCTLQueue_Fill128(__dpctl_keep const DPCTLSyclQueueRef QRef,
11841184
size_t Count)
11851185
{
11861186
auto Q = unwrap<queue>(QRef);
1187-
if (Q && USMRef) {
1187+
if (Q && USMRef && Value) {
11881188
sycl::event ev;
11891189
try {
11901190
complexNumber Val;
@@ -1198,8 +1198,8 @@ DPCTLQueue_Fill128(__dpctl_keep const DPCTLSyclQueueRef QRef,
11981198
return wrap<event>(new event(std::move(ev)));
11991199
}
12001200
else {
1201-
error_handler("QRef or USMRef passed to fill128 were NULL.", __FILE__,
1202-
__func__, __LINE__);
1201+
error_handler("QRef, USMRef, or Value passed to fill128 were NULL.",
1202+
__FILE__, __func__, __LINE__);
12031203
return nullptr;
12041204
}
12051205
}
@@ -1213,7 +1213,7 @@ DPCTLQueue_Fill128WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
12131213
size_t DepEventsCount)
12141214
{
12151215
auto Q = unwrap<queue>(QRef);
1216-
if (Q && USMRef) {
1216+
if (Q && USMRef && Value) {
12171217
sycl::event ev;
12181218
try {
12191219
std::vector<event> dep_events;
@@ -1236,8 +1236,9 @@ DPCTLQueue_Fill128WithEvents(__dpctl_keep const DPCTLSyclQueueRef QRef,
12361236
return wrap<event>(new event(std::move(ev)));
12371237
}
12381238
else {
1239-
error_handler("QRef or USMRef passed to fill128_async were NULL.",
1240-
__FILE__, __func__, __LINE__);
1239+
error_handler(
1240+
"QRef, USMRef, or Value passed to fill128_async were NULL.",
1241+
__FILE__, __func__, __LINE__);
12411242
return nullptr;
12421243
}
12431244
}

libsyclinterface/tests/test_sycl_queue_interface.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,10 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckFill128)
795795
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
796796
ASSERT_FALSE(p == nullptr);
797797

798+
ASSERT_NO_FATAL_FAILURE(
799+
Fill128_ERef = DPCTLQueue_Fill128(QRef, (void *)p, nullptr, nelems));
800+
ASSERT_FALSE(bool(Fill128_ERef));
801+
798802
ASSERT_NO_FATAL_FAILURE(
799803
Fill128_ERef = DPCTLQueue_Fill128(
800804
QRef, (void *)p, reinterpret_cast<uint64_t *>(&val), nelems));
@@ -993,6 +997,10 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckFill128WithEvents)
993997
ASSERT_NO_FATAL_FAILURE(p = DPCTLmalloc_device(nbytes, QRef));
994998
ASSERT_FALSE(p == nullptr);
995999

1000+
ASSERT_NO_FATAL_FAILURE(Fill_ERef = DPCTLQueue_Fill128WithEvents(
1001+
QRef, (void *)p, nullptr, nelems, nullptr, 0));
1002+
ASSERT_FALSE(bool(Fill_ERef));
1003+
9961004
ASSERT_NO_FATAL_FAILURE(
9971005
FillDep_ERef = DPCTLQueue_Fill128(
9981006
QRef, (void *)p, reinterpret_cast<uint64_t *>(&zero), nelems));

0 commit comments

Comments
 (0)