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.2p0 | CONFIDENTIAL | CodeSecure Inc |
The value of errno is tested, but the last function call was not to a function that can set errno.
For this warning class, CodeSonar will treat a function as setting errno if it is specified using the ERRNO_SETTING_FUNCTIONS configuration parameter.
ERRNO_SETTING_FUNCTIONS += f
| クラス名 | Inappropriate Test of Error Code | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Inappropriate Test of Error Code | |||||||||||||||||||||
| クラス分類 | スタイル (style) | |||||||||||||||||||||
| ニーモニック | LANG.ERRCODE.ITEST | |||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
|||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Inappropriate Test of Error Code" |
#include <errno.h>
#include <stdio.h>
void noerrno(void){
/* errno is never set by noerrno() or any of its callees */
}
int test_ftell_errno(FILE *fp){
(void) ftell(fp);
if (errno !=0) { /* ok: last function call was to ftell(), which can set errno */
return 1;
}
return 0;
}
int test_noerrno_errno(void){
noerrno();
if (errno != 0) { /* 'Inappropriate Test of Error Code' warning issued here
* - last function call was to noerrno(), which never sets errno
*/
return 1;
}
return 0;
}
int test_errno_path(FILE *fp, int i){
if (i > 0){
(void) ftell(fp);
}
else {
noerrno();
}
if (errno != 0){ /* 'Inappropriate Test of Error Code' warning issued here
* - on paths where i<=0 the last function call was to noerrno(), which never sets errno
*/
return 1;
}
return 0;
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。
To report problems with this documentation, please visit https://support.codesecure.com/.