From fcbccab4d1970479df338c4d1809378cb3ea3749 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Thu, 27 Jun 2024 09:46:33 +0200 Subject: [PATCH] [NFC] math_brute_force: drop unneeded gotos (#1843) Simplify code by returning directly instead of using goto statements. Signed-off-by: Sven van Haastregt --- .../math_brute_force/i_unary_double.cpp | 14 ++++++-------- .../math_brute_force/i_unary_float.cpp | 14 ++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/test_conformance/math_brute_force/i_unary_double.cpp b/test_conformance/math_brute_force/i_unary_double.cpp index 953c33bbb..2ed808744 100644 --- a/test_conformance/math_brute_force/i_unary_double.cpp +++ b/test_conformance/math_brute_force/i_unary_double.cpp @@ -98,7 +98,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) vlog_error( "\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", error, j); - goto exit; + return error; } } else @@ -124,13 +124,13 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) sizeof(gOutBuffer[j]), &gOutBuffer[j]))) { LogBuildError(programs[j]); - goto exit; + return error; } if ((error = clSetKernelArg(kernels[j][thread_id], 1, sizeof(gInBuffer), &gInBuffer))) { LogBuildError(programs[j]); - goto exit; + return error; } if ((error = clEnqueueNDRangeKernel(gQueue, kernels[j][thread_id], @@ -138,7 +138,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) NULL, NULL))) { vlog_error("FAILED -- could not execute kernel\n"); - goto exit; + return error; } } @@ -159,7 +159,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) BUFFER_SIZE, gOut[j], 0, NULL, NULL))) { vlog_error("ReadArray failed %d\n", error); - goto exit; + return error; } } @@ -188,8 +188,7 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) "\nERROR: %sD%s: %d ulp error at %.13la: *%d vs. %d\n", f->name, sizeNames[k], err, ((double *)gIn)[j], t[j], q[j]); - error = -1; - goto exit; + return -1; } } } @@ -221,6 +220,5 @@ int TestFunc_Int_Double(const Func *f, MTdata d, bool relaxedMode) vlog("\n"); -exit: return error; } diff --git a/test_conformance/math_brute_force/i_unary_float.cpp b/test_conformance/math_brute_force/i_unary_float.cpp index 0ce37cc8c..0df35c4ad 100644 --- a/test_conformance/math_brute_force/i_unary_float.cpp +++ b/test_conformance/math_brute_force/i_unary_float.cpp @@ -97,7 +97,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) vlog_error( "\n*** Error %d in clEnqueueWriteBuffer2(%d) ***\n", error, j); - goto exit; + return error; } } else @@ -123,13 +123,13 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) sizeof(gOutBuffer[j]), &gOutBuffer[j]))) { LogBuildError(programs[j]); - goto exit; + return error; } if ((error = clSetKernelArg(kernels[j][thread_id], 1, sizeof(gInBuffer), &gInBuffer))) { LogBuildError(programs[j]); - goto exit; + return error; } if ((error = clEnqueueNDRangeKernel(gQueue, kernels[j][thread_id], @@ -137,7 +137,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) NULL, NULL))) { vlog_error("FAILED -- could not execute kernel\n"); - goto exit; + return error; } } @@ -158,7 +158,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) BUFFER_SIZE, gOut[j], 0, NULL, NULL))) { vlog_error("ReadArray failed %d\n", error); - goto exit; + return error; } } @@ -187,8 +187,7 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) "*%d vs. %d\n", f->name, sizeNames[k], err, ((float *)gIn)[j], ((cl_uint *)gIn)[j], t[j], q[j]); - error = -1; - goto exit; + return -1; } } } @@ -219,6 +218,5 @@ int TestFunc_Int_Float(const Func *f, MTdata d, bool relaxedMode) vlog("\n"); -exit: return error; }