我对以下 C 代码运行了 MISRA 2004 和 MISRA 2012 的静态代码分析:
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;
}
有人可以解释一下第 58 行和第 66 行的代码是如何产生副作用的吗?我应该如何纠正它?