From 2318cedb21514fd9fe7030ba196bdaebf89467c9 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 31 Jan 2023 17:50:21 +0000 Subject: [PATCH] select: Use MTdataHolder (#1609) Simplify code by avoiding manual resource management. This fixes use of an uninitialized `d` in the `free_mtdata` call, in the case a `goto exit` was executed before initializing `d`. Signed-off-by: Sven van Haastregt --- test_conformance/select/test_select.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test_conformance/select/test_select.cpp b/test_conformance/select/test_select.cpp index 972a53c6..7fa3bc08 100644 --- a/test_conformance/select/test_select.cpp +++ b/test_conformance/select/test_select.cpp @@ -295,7 +295,7 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c { int err = CL_SUCCESS; int s_test_fail = 0; - MTdata d; + MTdataHolder d; const size_t element_count[VECTOR_SIZE_COUNT] = { 1, 2, 3, 4, 8, 16 }; cl_mem src1 = NULL; cl_mem src2 = NULL; @@ -368,7 +368,7 @@ static int doTest(cl_command_queue queue, cl_context context, Type stype, Type c cmp_stride = block_elements * step * (0xffffffffffffffffULL / 0x100000000ULL + 1); log_info("Testing..."); - d = init_genrand( gRandomSeed ); + d = MTdataHolder(gRandomSeed); uint64_t i; for (i=0; i < blocks; i+=step) { @@ -460,7 +460,6 @@ exit: if( ref ) free(ref ); if( sref ) free(sref ); - free_mtdata(d); for (vecsize = 0; vecsize < VECTOR_SIZE_COUNT; vecsize++) { clReleaseKernel(kernels[vecsize]); clReleaseProgram(programs[vecsize]);