From a87e686757f9fda5377baf73a32bb3c791eae70c Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Fri, 16 Sep 2022 13:34:36 +0100 Subject: [PATCH] Fix more warnings in math_brute_force (#1502) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix "‘nadj’ may be used uninitialized in this function [-Werror=maybe-uninitialized]". * Fix "specified bound 4096 equals destination size [-Werror=stringop-truncation]". Signed-off-by: Sven van Haastregt --- test_conformance/math_brute_force/main.cpp | 8 +++++--- test_conformance/math_brute_force/reference_math.cpp | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test_conformance/math_brute_force/main.cpp b/test_conformance/math_brute_force/main.cpp index 8cebff9d..ee3fcbd9 100644 --- a/test_conformance/math_brute_force/main.cpp +++ b/test_conformance/math_brute_force/main.cpp @@ -360,16 +360,18 @@ static int ParseArgs(int argc, const char **argv) int singleThreaded = 0; { // Extract the app name - strncpy(appName, argv[0], MAXPATHLEN); + strncpy(appName, argv[0], MAXPATHLEN - 1); + appName[MAXPATHLEN - 1] = '\0'; #if defined(__APPLE__) char baseName[MAXPATHLEN]; char *base = NULL; - strncpy(baseName, argv[0], MAXPATHLEN); + strncpy(baseName, argv[0], MAXPATHLEN - 1); + baseName[MAXPATHLEN - 1] = '\0'; base = basename(baseName); if (NULL != base) { - strncpy(appName, base, sizeof(appName)); + strncpy(appName, base, sizeof(appName) - 1); appName[sizeof(appName) - 1] = '\0'; } #endif diff --git a/test_conformance/math_brute_force/reference_math.cpp b/test_conformance/math_brute_force/reference_math.cpp index f91ecb22..afa072f8 100644 --- a/test_conformance/math_brute_force/reference_math.cpp +++ b/test_conformance/math_brute_force/reference_math.cpp @@ -1949,7 +1949,8 @@ double reference_lgamma(double x) w6 = -1.63092934096575273989e-03; /* 0xBF5AB89D, 0x0B9E43E4 */ static const double zero = 0.00000000000000000000e+00; - double t, y, z, nadj, p, p1, p2, p3, q, r, w; + double nadj = zero; + double t, y, z, p, p1, p2, p3, q, r, w; cl_int i, hx, lx, ix; union {