Crinit -- Configurable Rootfs Init
|
Header for common definitions not related to other specific features. More...
Go to the source code of this file.
Macros | |
#define | CRINIT_PARAM_UNUSED(par) |
#define | crinitParamCheck(inputParam, cmpShort, cmpLong) ((strncmp(inputParam, cmpShort, sizeof(cmpShort)) == 0) || (strncmp(inputParam, cmpLong, sizeof(cmpLong)) == 0)) |
#define | crinitIsAbsPath(path) (((path) != NULL) && ((path)[0] == '/')) |
#define | crinitNumElements(p) (sizeof(p) / sizeof(*(p))) |
#define | crinitNullCheck(errcode, ...) |
#define | crinitStrtoGenericInteger(resType, str, endptr, base) |
#define | crinitNullify(ptr) |
Header for common definitions not related to other specific features.
#define CRINIT_PARAM_UNUSED | ( | par | ) |
Suppress unused parameter warning for variable as per coding guideline [OS_C_UNUSED_010]
.
May be needed if an external interface is implemented.
par | Unused variable that should not be warned about. |
#define crinitIsAbsPath | ( | path | ) | (((path) != NULL) && ((path)[0] == '/')) |
Check if path is absolute (i.e. starts with '/').
path | The path to check. |
#define crinitNullCheck | ( | errcode, | |
... | |||
) |
Macro to simplify checking for null pointer inputs at the start of a function.
Will print an error message and return from the calling function with the given error code if any of the given variables are NULL.
Declares the variables _macroPtrsToCheck
and _macroI
internally. These names must not be used as parameter names to functions which use this macro.
errcode | The error code to return if expr is false. Must be a compatible type to the return type of the encompassing function. |
... | Variadic list of parameter names to check if they are NULL. |
#define crinitNullify | ( | ptr | ) |
Convenience macro to free memory and also set the pointer to it to NULL.
ptr | The pointer to be "nullified". |
#define crinitNumElements | ( | p | ) | (sizeof(p) / sizeof(*(p))) |
Calculate the number of elements of an array at compile-time.
#define crinitParamCheck | ( | inputParam, | |
cmpShort, | |||
cmpLong | |||
) | ((strncmp(inputParam, cmpShort, sizeof(cmpShort)) == 0) || (strncmp(inputParam, cmpLong, sizeof(cmpLong)) == 0)) |
Checks if a string is equal to at least one of two comparison literals.
Meant to be used in a loop to check argv for long and short options. Parameters must not be NULL.
inputParam | pointer to a c string to be compared, may be const |
cmpShort | first comparison string literal, meant for the short form of the option |
cmpLong | second comparison string literal, meant for the long form of the option |
#define crinitStrtoGenericInteger | ( | resType, | |
str, | |||
endptr, | |||
base | |||
) |
Macro for a type-generic implementation of strto*()
.
Example: unsigned long x = strtoGenericInteger(x, "0xFF", NULL, 16);
will map to unsigned long x = strtoul("0xFF", NULL, 16);
.