JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
変数に代入された値は、その後の実行パスで使用されていません。
定数への代入によって発生する未使用の値に対する警告は、プロジェクト設定ファイルにおいて REPORT_UNUSED_ASSIGNMENTS_FROM_CONSTANTS が Yesに設定されている場合にのみ発行されます。 デフォルトではこの設定はNoとなっている為、CodeSonar で未使用値の警告を発行する場合は、設定を変更する必要があります。
| クラス名 | Unused Value | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | 未使用の値 | |||||||||||||||||||||||||||||||||||||||
| クラス分類 | 冗長性 (redundancy) | |||||||||||||||||||||||||||||||||||||||
| ニーモニック | LANG.STRUCT.UUVAL | |||||||||||||||||||||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Unused Value" |
#include <stdlib.h>
int lang_struct_uuval_constant(void){
int x;
x = 3; /* 'Unused Value' warning only issued here if
* REPORT_UNUSED_ASSIGNMENTS_FROM_CONSTANTS=Yes,
* because the assignment is to a constant.
*/
x = 4;
return x;
}
int lang_struct_uuval_rand(void){
int x;
x = rand(); /* 'Unused Value' warning issued here regardless
* of setting of REPORT_UNUSED_ASSIGNMENTS_FROM_CONSTANTS,
* because the assignment is NOT to a constant.
*/
x = 4;
return x;
}
int lang_struct_uuval_multipath(void){
int i = rand(); /* 'Unused Value' warning issued here: this value is
* overwritten on both branches of the IF statement.
*/
int j = rand(); /* ok: this value is used when k ≥ 5 */
int k = rand();
if (k < 5){
i = k;
j = 5;
}
else {
i = 6;
}
return i + j;
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。