Externals-CStdLib.Errno¶
Configuration of the implementation of the global ‘errno’ variable provided in the C stdlib
The number of last error of C system library calls is provided by
the symbol errno. This symbol can be implemented in different ways
in the header errno.h, e.g. as a global variable or as a macro
dereferencing the result of a function call. E.g.:
errno_t errno;#define errno (*_errno())
Please use this configuration rule to adapt the detection mechanism to the
project's standard library's errno.h.
In addition, the predefined set of
out-of-band and
in-band errno setting
functions may be adapted.
Possible Messages
This rule has no predefined messages.
Options¶
The following places define options that affect this rule: Analysis-GlobalOptions
function_from_macro_pattern¶
function_from_macro_pattern
Regular expression with one group. That group's matching string is added to the set function_names. This is intended to auto-detect patterns likeType: typing.Pattern[str]
Default:
'\s*(?:\(|)\s*\*\s*(?:\([a-z]+\s*\*?\))?\s*([_a-zA-Z][_a-zA-Z0-9]*)\s*\(\s*\)\s*(?:\)|)\s*'
#define errno (*_errno()).
function_names¶
function_names : set[bauhaus.analysis.config.QualifiedName] = set()
errno functionality via an
indirect call. Simple cases can be auto-detected via the
function_from_macro_pattern option.
More complex cases can be configured here.
in_band_error_funcs¶
in_band_error_funcs
A dictionary ofType: dict[str, str | int]
Default:
{ 'fgetwc': 'WEOF', 'fputwc': 'WEOF', 'strtod': 'HUGE_VAL', 'strtof': 'HUGE_VALF', 'strtoimax': 'INTMAX_MAX', 'strtol': 'LONG_MAX', 'strtold': 'HUGE_VALL', 'strtoll': 'LLONG_MAX', 'strtoul': 'ULONG_MAX', 'strtoull': 'ULLONG_MAX', 'strtoumax': 'UINTMAX_MAX', 'wcstod': 'HUGE_VAL', 'wcstof': 'HUGE_VALF', 'wcstoimax': 'INTMAX_MAX', 'wcstol': 'LONG_MAX', 'wcstold': 'HUGE_VALL', 'wcstoll': 'LLONG_MAX', 'wcstoul': 'ULONG_MAX', 'wcstoull': 'ULLONG_MAX', 'wcstoumax': 'UINTMAX_MAX' }
errno setting functions similar to
out_of_band_error_funcs.
For in-band errno setting function the returned value does not uniquely
determine if actually an error occurred. The returned value may also be a valid
result. Therefore, if a potential error value is returned, errno should
be checked additionally. And for properly checking errno,
errno should have been initialized to zero before calling any of these
errno setting functions. For the strings HUGE_VAL,
HUGE_VALF, and HUGE_VALL also 0 and the corresponding
negative values indicate an error. For the signed types the values
INTMAX_MAX, LONG_MAX, and LLONG_MAX also
corresponding values INTMAX_MIN, LONG_MIN, and
LLONG_MIN are addressed.
macro_names¶
macro_names : set[bauhaus.analysis.config.MacroName] = {'errno'}
errno (typically just
errno).
out_of_band_error_funcs¶
out_of_band_error_funcs
A dictionary ofType: dict[str, str | int]
Default:
{ 'c16rtomb': 'max_size', 'c32rtomb': 'max_size', 'fgetpos': 'nonzero', 'fsetpos': 'nonzero', 'ftell': -1, 'mbrtoc16': 'max_size', 'mbrtoc32': 'max_size', 'mbrtowc': 'max_size', 'mbsrtowcs': 'max_size', 'signal': 'SIG_ERR', 'wcrtomb': 'max_size', 'wcsrtombs': 'max_size' }
errno setting functions that return the given value in
case of an error. The string max_size is the maximal value of a
size_t type. The string nonzero denotes any non 0 value
and testing is done in the same way as for 0, namely by testing equality or
inequality with 0. For out-of-band errno setting functions there is no
need to ever set or read errno as the return value is sufficient as
error indication. However, errno may provide additional error
information.
posix_error_funcs¶
posix_error_funcs
An extra dictionary of in-bandType: dict[str, str | int]
Default:
{ 'chmod': -1, 'chown': -1, 'close': 'EOF', 'creat': -1, 'fchmod': -1, 'fchmodat': -1, 'fchown': -1, 'fchownat': -1, 'fclose': 'EOF', 'fcntl': -1, 'fdatasync': -1, 'fdopen': 'NULL', 'fflush': 'EOF', 'fopen': 'NULL', 'freopen': 'NULL', 'fstat': -1, 'fstatat': -1, 'fsync': -1, 'ioctl': -1, 'lchown': -1, 'lstat': -1, 'open': -1, 'openat': -1, 'pread': -1, 'read': -1, 'stat': -1, 'wait': -1, 'waitid': -1, 'waitpid': -1 }
errno setting functions for posix. See
in_band_error_funcs for further documentation.
These functions are considered by some errno rules via the
option standard_posix of the respective rule.
variable_names¶
variable_names : set[bauhaus.analysis.config.QualifiedName] = {'errno'}
errno (in simple
implementations errno).