From dde956b085512fd5dc4982ba3e713db99255eae1 Mon Sep 17 00:00:00 2001 From: Swasti Shrivastava <37058682+swasti16@users.noreply.github.com> Date: Sun, 15 Oct 2023 21:03:35 +0530 Subject: [PATCH] Fix 10855,11752:False positive: misra-c2012-22.10 (#5557) --- addons/misra.py | 4 ++-- addons/test/misra/misra-test.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index ed504b6df14..59d6d336f27 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -3849,8 +3849,8 @@ def misra_22_9(self, cfg): def misra_22_10(self, cfg): last_function_call = None for token in cfg.tokenlist: - if token.str == '(' and not simpleMatch(token.link, ') {'): - name, args = cppcheckdata.get_function_call_name_args(token.previous) + if token.isName and token.next.str == '(' and not simpleMatch(token.next.link, ') {'): + name, args = cppcheckdata.get_function_call_name_args(token) last_function_call = name if token.str == '}': last_function_call = None diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index ef602a1353f..ac0ab32ea10 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -1929,4 +1929,13 @@ static void misra_22_10(void) errno = 0; f = strtod ( "A.12", NULL ); if ( 0 == errno ) {} + + // #10855 + f = strtol(numbuf, 0, (formatHex == 0U) ? 0 : 16); + if (errno != 0) {} + + // #11752 + #define NULL_PTR ((void*)0) + f = strtod(inStr, NULL_PTR); + if(errno != 0) {} }