I ran static code analysis for MISRA 2004 and MISRA 2012 on the following C code:
BOOL_TYPE Strings_Are_Equal(const char *s1, const char *s2)
{
BOOL_TYPE result = True;
const char *str1 = s1;
const char *str2 = s2;
if (NULL == s1 || NULL == s2)
{
result = False;
}
else if (strlen(s1) != strlen(s2))
{
result = False;
}
else
{
while (*str1 != 0)
{
if(tolower(*str1++) != tolower(*str2++))
{
result = False;
break;
}
}
}
return result;
}
and got the following findings from the PC-lint reports:
Can somebody please explain how is code at line 58 and 66 is suffering from side effects and how should I correct it?