Skip to content

Commit

Permalink
Fix #12079: Misra: calling unknown function in condition => false pos…
Browse files Browse the repository at this point in the history
…itive 14.4, missing misra-config warning
  • Loading branch information
swasti16 committed Oct 17, 2023
1 parent dd76504 commit 34e6454
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2805,7 +2805,9 @@ def misra_14_4(self, data):
continue
if not token.astOperand1 or not (token.astOperand1.str in ['if', 'while']):
continue
if not isBoolExpression(token.astOperand2):
if isBoolExpression(token.astOperand2):
continue
if token.astOperand2.valueType:
self.reportError(token, 14, 4)

def misra_15_1(self, data):
Expand Down
13 changes: 8 additions & 5 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ static void foo(void)
{
for(i = 0; i < 10; i++)
{
if(misra_5_2_func3()) //14.4
if(misra_5_2_func3())
{
int misra_5_2_var_hides_var_1____31x;
int misra_5_2_var_hides_var_1____31y;//5.2
}
}
} while(misra_5_2_func2()); //14.4
} while(misra_5_2_func2());
}
break;
}
Expand Down Expand Up @@ -252,11 +252,11 @@ static void misra_5_5_func1(void)
{
do
{
if(misra_5_5_func3()) //14.4
if(misra_5_5_func3())
{
int misra_5_5_hides_macro________31y; //5.5
}
} while(misra_5_5_func2()); //14.4
} while(misra_5_5_func2());
}
break;
}
Expand Down Expand Up @@ -1297,13 +1297,16 @@ struct {
unsigned int y:1;
} r14_4_struct; // 8.4
static void misra_14_4(bool b) {
if (x+4){} // 14.4
if (x+4){}
else {}

if (b) {}
else {}

if (r14_4_struct.x) {}

// #12079
if (z) {}
}

static void misra_15_1(void) {
Expand Down

0 comments on commit 34e6454

Please sign in to comment.