Skip to content

Commit

Permalink
Fix #12172:False positive: misra-11.1 function pointer assigned to array
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti16 committed Nov 15, 2023
1 parent 282c195 commit 39dd29f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@ def get_function_pointer_type(tok):
ret += '('
tok = tok.next.next
while tok and (tok.str not in '()'):
ret += ' ' + tok.str
if tok.varId is None:
ret += ' ' + tok.str
tok = tok.next
if (tok is None) or tok.str != ')':
return None
Expand Down
7 changes: 7 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,13 @@ static void misra_10_8(u8 x, s32 a, s32 b) {
int (*misra_11_1_p)(void); // 8.4
void *misra_11_1_bad1 = (void*)misra_11_1_p; // 11.1 8.4

// #12172
typedef void (*pfFunc)(uint32_t some);
extern pfFunc data[10];
void f(pfFunc ptr){ //8.4
data[index] = ptr;
}

struct misra_11_2_s;
struct misra_11_2_t;

Expand Down

0 comments on commit 39dd29f

Please sign in to comment.