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 |
An atomic variable is accessed, but it has not been initialized. There are two cases:
For the sake of this check, a variable is considered to be atomic if it is declared with the _Atomic type specifier or has any atomic type defined in <stdatomic.h>.
Note: if an atomic variable is used without being initialized, CodeSonar will issue an Uninitialized Variable warning.
| クラス名 | Inappropriate C Atomic Initialization | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Inappropriate C Atomic Initialization | ||||||||||||||||||
| クラス分類 | 信頼性 (reliability) | ||||||||||||||||||
| ニーモニック | CONCURRENCY.C_ATOMIC.INIT | ||||||||||||||||||
| カテゴリー |
|
||||||||||||||||||
| 対応言語 | C および C++ で利用可能です。 |
||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル
(configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Inappropriate C Atomic Initialization" |
#include <stdint.h>
#include <stdatomic.h>
int32_t concurrency_c_atomic_init( void ){
_Atomic int32_t good1 = 111; /* ok: direct initialization */
_Atomic int32_t good2;
int32_t _Atomic * goodp;
_Atomic int32_t bad1;
_Atomic int32_t bad2;
_Atomic int32_t bad3;
int32_t _Atomic * badp;
atomic_init(&good2, 222); /* ok: initialization with atomic_init() */
good1 = 555; /* ok: good1 previously initialized */
goodp = &good2; /* ok: good2 previously initialized */
bad1 = 333; /* 'Inappropriate C Atomic Initialization' warning issued here
* - not direct initialization and not using atomic_init()
*/
badp = &bad2; /* 'Inappropriate C Atomic Initialization' warning issued here
* - taking address of uninitialized atomic variable
*/
*badp = 444; /* 'Inappropriate C Atomic Initialization' warning issued here
* - writing through pointer into uninitialized atomic variable
*/
return bad3; /* 'Uninitialized Variable' warning issued here
* - use of ininitialized atomic variable
*/
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。