Skip to content

Commit

Permalink
mem_host_flags: check returned pointer for NULL (#1924)
Browse files Browse the repository at this point in the history
The specification states that `clEnqueueMapImage` and
`clEnqueueMapBuffer` should return NULL on error. Ensure this is
checked.

This testing gap was caught by a compiler warning about `dataPtr` being
written but not read. With this fix, there are no more
Wunused-but-set-variable warnings in this test, so reenable the warning.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
  • Loading branch information
svenvh authored May 29, 2024
1 parent 6807e16 commit 1d3ad8d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 0 additions & 2 deletions test_conformance/mem_host_flags/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@ set(${MODULE_NAME}_SOURCES
mem_host_image.cpp
)

set_gnulike_module_compile_flags("-Wno-unused-but-set-variable")

include(../CMakeCommon.txt)
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ cl_int cImage_check_mem_host_no_access<T>::verify_RW_Image_Mapping()
err = FAILURE;
return err;
}
else if (dataPtr != nullptr)
{
log_error("Calling clEnqueueMapImage (CL_MAP_WRITE) on a memory object "
"created with the CL_MEM_HOST_NO_ACCESS flag should fail "
"and return NULL\n");
err = FAILURE;
return err;
}
else
{
log_info("Test succeeded\n\n");
Expand All @@ -154,6 +162,14 @@ cl_int cImage_check_mem_host_no_access<T>::verify_RW_Image_Mapping()
err = FAILURE;
return err;
}
else if (dataPtr != nullptr)
{
log_error("Calling clEnqueueMapImage (CL_MAP_READ) on a memory object "
"created with the CL_MEM_HOST_NO_ACCESS flag should fail "
"and return NULL\n");
err = FAILURE;
return err;
}
else
{
log_info("Test succeeded\n\n");
Expand Down
17 changes: 17 additions & 0 deletions test_conformance/mem_host_flags/checker_mem_host_no_access.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ cl_int cBuffer_check_mem_host_no_access<T>::verify_RW_Buffer_mapping()
err = FAILURE;
return FAILURE;
}
else if (dataPtr != nullptr)
{
log_error("Calling clEnqueueMapBuffer (CL_MAP_READ) on a memory object "
"created with the CL_MEM_HOST_NO_ACCESS flag should fail "
"and return NULL\n");
err = FAILURE;
return err;
}
else
{
log_info("Test succeeded\n\n");
Expand All @@ -207,6 +215,15 @@ cl_int cBuffer_check_mem_host_no_access<T>::verify_RW_Buffer_mapping()
err = FAILURE;
return FAILURE;
}
else if (dataPtr != nullptr)
{
log_error(
"Calling clEnqueueMapBuffer (CL_MAP_WRITE) on a memory object "
"created with the CL_MEM_HOST_NO_ACCESS flag should fail "
"and return NULL\n");
err = FAILURE;
return err;
}
else
{
log_info("Test succeeded\n\n");
Expand Down

0 comments on commit 1d3ad8d

Please sign in to comment.