From 6541f52e61efcbb4e1f6db74f09139f36f258ce7 Mon Sep 17 00:00:00 2001
From: keinflue <80230456+keinflue@users.noreply.github.com>
Date: Sat, 1 May 2021 10:39:01 +0000
Subject: [PATCH] Fix false positive invalidFunctionArg for zero arguments to
calloc. (#3238)
---
cfg/std.cfg | 2 +-
test/testfunctions.cpp | 7 +++----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/cfg/std.cfg b/cfg/std.cfg
index 95a1504c3..f6ed7951c 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -945,7 +945,7 @@
- 1:
+ 0:
diff --git a/test/testfunctions.cpp b/test/testfunctions.cpp
index cd44d06a3..4ee234c4b 100644
--- a/test/testfunctions.cpp
+++ b/test/testfunctions.cpp
@@ -433,11 +433,10 @@ private:
"}");
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid memset() argument nr 3. A non-boolean value is required.\n", errout.str());
- check("void boolArgZeroIsInvalidButOneIsValid(int param) {\n"
- " void* buffer = calloc(param > 0, 10);\n"
- " free(buffer);\n"
+ check("int boolArgZeroIsInvalidButOneIsValid(int a, int param) {\n"
+ " return div(a, param > 0);\n"
"}");
- ASSERT_EQUALS("[test.cpp:2]: (error) Invalid calloc() argument nr 1. The value is 0 or 1 (boolean) but the valid values are '1:'.\n", errout.str());
+ ASSERT_EQUALS("[test.cpp:2]: (error) Invalid div() argument nr 2. The value is 0 or 1 (boolean) but the valid values are ':-1,1:'.\n", errout.str());
check("void boolArgZeroIsValidButOneIsInvalid(int param) {\n"
" strtol(a, b, param > 0);\n"