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 code calls a function f() that will set an error code (such as errno) on failure, but the error code is not set to zero (0) before the call. This means that if the error code is non-zero after calling f(), it may have been set by some earlier function call and not by f().
| Class Name | Non-zero Error Code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mnemonic | LANG.ERRCODE.NZ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Categories |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Availability | Available for C and C++. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Enabling | Checks for this warning class are
disabled by default. To enable them, add the following WARNING_FILTER
rule to the project configuration file.
WARNING_FILTER += allow class="Non-zero Error Code" |
#include <errno.h>
#include <stdio.h>
void errno_nonzero(FILE *fp1, FILE *fp2){
errno=0;
(void) fseek(fp1, 0L, 0); /* ok: errno set to 0 immediately before call */
(void) ftell(fp1); /* 'Non-zero Error Code' warning issued here
* - errno not set to 0 before call to ftell()
* - if errno was set by the fseek() call, this value is not cleared
*/
if (errno==0){
(void) ftell(fp2); /* ok: call only occurs on path where errno==0 */
}
else {
/* handle error */ /* errno!=0 may have been caused by the ftell(fp1) call, but it may
* also have been caused by the fseek() call. */
}
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.