mem_host_flags: check returned pointer for NULL (#1924)

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>
This commit is contained in:
Sven van Haastregt
2024-05-30 00:11:32 +02:00
committed by GitHub
parent 6807e165d7
commit 1d3ad8d791
3 changed files with 33 additions and 2 deletions

View File

@@ -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)

View File

@@ -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");
@@ -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");

View File

@@ -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");
@@ -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");