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 |
A variable is assigned a value, but that value is never subsequently used on any execution path.
Warnings for unused values arising from assignments to constants are only issued if configuration parameter REPORT_UNUSED_ASSIGNMENTS_FROM_CONSTANTS is set to Yes. Its factory setting is No, so you will need to explicitly change the setting if you want CodeSonar to issue Unused Value warnings in these cases.
| Class Name | Unused Value | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | redundancy | ||||||||||||||||||||||||||||||||||||||||||
| Mnemonic | LANG.STRUCT.UUVAL | ||||||||||||||||||||||||||||||||||||||||||
| Categories |
|
||||||||||||||||||||||||||||||||||||||||||
| Availability | Available for C and C++. |
||||||||||||||||||||||||||||||||||||||||||
| Enabling | Checks for this warning class are enabled by
default. To disable them, add the following WARNING_FILTER rule to the
project configuration file.
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;
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.