次の 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行目のコードがどのように副作用に悩まされているのか、またどのように修正すればよいのか、誰か説明してもらえますか?