From 830d9f147d2a55d2456b2a164f8a42f529c1907d Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 19 Jan 2016 16:39:17 +1100 Subject: [PATCH] Correct cppcheck warning that could occur when all elements are <= 1 cppcheck -DDBUG_VOID_RETURN=return -"DDBUG_RETURN(a)=return a" mysys/testhash.c [mysys/testhash.c:172]: (error) Array 'key1[1000]' accessed at index 1000, which is out of bounds. --- mysys/testhash.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysys/testhash.c b/mysys/testhash.c index ffdaaec..0653e7f 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -169,6 +169,11 @@ static int do_test() for (j=0 ; j < 1000 ; j++) if (key1[j] > 1) break; + if (j >= 1000) + { + printf("All keys are <= 1 "); + goto err; + } if (key1[j] > 1) { HASH_SEARCH_STATE state;