C and C++


MISC.NOEFFECT : 無意味な関数呼出し

要旨

何も影響を与えない関数呼び出しです。

このクラスのワーニングは、サイズ引数が0となるメモリコピー関数呼び出しをチェックします。

プロパティ

クラス名 Function Call Has No Effect
日本語クラス名 無意味な関数呼出し
クラス分類 セキュリティ (security)
ニーモニック MISC.NOEFFECT
カテゴリー
MisraC2023 MisraC2023:2.2 A project shall not contain dead code
Misra2012 Misra2012:2.2 A project shall not contain dead code
Misra2004 Misra2004:14.2 All non-null statements shall either (a) have at least one side-effect however executed, or (b) cause control flow to change
AUTOSARC++14 AUTOSARC++14:M0-1-8 All functions with void return type shall have external side effect(s).
  AUTOSARC++14:M0-1-9 There shall be no dead code.
MisraC++2008 MisraC++2008:0-1-8 All functions with void return type shall have external side effect(s).
  MisraC++2008:0-1-9 There shall be no dead code.
CWE CWE:687 Function Call With Incorrectly Specified Argument Value
  CWE:688 Function Call With Incorrect Variable or Reference as Argument
  CWE:1164 Irrelevant Code
CERT-C CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:187 All non-null statements shall potentially have a side-effect.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Function Call Has No Effect"

可能性のあるカテゴリ

CWE:683 Function Call With Incorrect Order of Arguments

以下は、 memset() 呼び出しで全ての buf 領域に '\0' を設定しようとした意図に反し、引数の順序を間違えた例です。

#include <string.h>

void f()
{
    char buf[10];
    memset(buf, 10, '\0'); /* Function Call Has No Effect
                            * warning issued here */
}

ワーニングを引き起こす関数

CodeSonar ships with library models that allow it to functions such as libc memcpy() and Win32 StrCatBuffA()/StrCatBuffW() that copy a specified amount of memory. If one of these functions is called with a constant-valued expression that evaluates to zero in the length parameter position, a warning will be issued.

If you have created a custom library model for some function f() in terms of one of these existing models, calls to f() will also be capable of triggering Function Call Has No Effect warnings.

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。