NVIDIA DriveOS Linux SDK API Reference

7.2.5.0 Early Access Release
nvos_static_analysis.h File Reference

Detailed Description

Macros/functions/etc for static analysis of code.

Definition in file nvos_static_analysis.h.

Go to the source code of this file.

Data Structures

union  flag_converter
 convert signedness of 32bit value More...
 

Macros

#define NVOS_EXIT(x)   _exit(x)
 
#define NVOS_MISRA(type, num)
 These macros are used for whitelisting coverity violations. More...
 
#define NVOS_CERT(num)
 
#define NVOS_COV_STRING(x)
 
#define NVOS_COV_WHITELIST(type, checker, comment_str)
 
#define NVOS_COV_WHITELIST_BLOCK_BEGIN(type, num, checker, comment_str)
 
#define NVOS_COV_WHITELIST_BLOCK_END(checker)
 
#define NVOS_COV_PEND_WHITELIST(checker, comment_str)
 
#define ERR_INT30_C_ADDU16   0x378
 Exit codes for function that call NVOS_EXIT(). More...
 
#define ERR_INT30_C_ADDU32   0x377
 
#define ERR_INT30_C_ADDU64   0x376
 
#define ERR_INT30_C_SUBU32   0x375
 
#define ERR_INT30_C_SUBU64   0x374
 
#define ERR_INT30_C_MULTU32   0x373
 
#define ERR_INT30_C_MULTU64   0x372
 
#define ERR_INT32_C_ADDS32   0x371
 
#define ERR_INT32_C_ADDS64   0x370
 
#define ERR_INT32_C_SUBS32   0x369
 
#define ERR_INT32_C_SUBS64   0x368
 
#define ERR_INT32_C_MULTS32   0x367
 
#define ERR_INT32_C_MULTS64   0x366
 
#define ERR_INT32_C_DIVS32   0x365
 
#define ERR_INT32_C_DIVS64   0x364
 
#define ERR_INT31_C_CAST_U64TOU8   0x361
 
#define ERR_INT31_C_CAST_U32TOS32   0x360
 
#define ERR_INT31_C_CAST_U32TOU16   0x359
 
#define ERR_INT31_C_CAST_U32TOU8   0x358
 
#define ERR_INT31_C_CAST_U64TOU32   0x357
 
#define ERR_INT31_C_CAST_U64TOS32   0x356
 
#define ERR_INT31_C_CAST_S32TOU32   0x355
 
#define ERR_INT31_C_CAST_S64TOU32   0x354
 
#define ERR_INT31_C_CAST_S32TOU64   0x353
 
#define ERR_INT31_C_CAST_S32TOU8   0x352
 
#define ERR_INT31_C_CAST_S64TOU64   0x351
 
#define ERR_INT31_C_CAST_S64TOS32   0x350
 
#define ERR_INT31_C_CAST_U64TOS64   0x34F
 
#define ERR_INT30_C_ADDU64UPTR   0x34E
 
#define ERR_INT30_C_ADDU32UPTR   0x34D
 
#define ERR_INT30_C_ADDU32VPTR   ERR_INT30_C_ADDU32UPTR
 
#define ERR_INT30_C_MULTSIZET   0x34C
 
#define VA_ADDR_MASK   0xFFFFFFFFFFFFUL
 Define macro for virtual address bit mask. More...
 
#define OFFSET_MASK   0xFFFFUL
 
#define NvBoolTrue   ((NvBoolVar)0xBABAFACEU)
 Define macro to replace boolean True. More...
 
#define NvBoolFalse   ((NvBoolVar)0x45450531U)
 Define macro to replace boolean False. More...
 
#define NV_UINTPTR_MAX   ((uintptr_t)0U - 1U)
 Define macro to replace uintptr_t max. More...
 

Typedefs

typedef uint32_t NvBoolVar
 

Functions

static bool AddU16 (uint16_t op1, uint16_t op2, uint16_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap. More...
 
static bool AddU32 (uint32_t op1, uint32_t op2, uint32_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap. More...
 
static bool AddS32 (int32_t op1, int32_t op2, int32_t *result)
 CERT INT30-C Precondition test to ensure that integer add operation do not wrap. More...
 
static bool AddU64 (uint64_t op1, uint64_t op2, uint64_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap. More...
 
static bool AddS64 (int64_t op1, int64_t op2, int64_t *result)
 CERT INT30-C Precondition test to ensure that integer add operation do not wrap. More...
 
static bool MultU32 (uint32_t op1, uint32_t op2, uint32_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap. More...
 
static bool MultU16 (uint16_t op1, uint16_t op2, uint16_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap. More...
 
static bool CastU64toU32 (uint64_t op1, uint32_t *result)
 CERT INT30-C: Precondition test to ensure casting unsigned long to unsigned integer do not wrap. More...
 
static void incrementUInt32 (uint32_t *x)
 Increment uint32_t by one Precondition test to ensure value is within RANGE_MAX. More...
 
static void incrementUInt64 (uint64_t *x)
 Increment uint64_t by one Precondition test to ensure value is within RANGE_MAX. More...
 
static bool CastU64toS32 (uint64_t op1, int32_t *result)
 CERT INT30-C: Precondition test to ensure casting unsigned long to unsigned integer do not wrap. More...
 
static bool CastU32toS32 (uint32_t op1, int32_t *result)
 CERT INT30-C: Precondition test to ensure casting unsigned integer to signed integer do not wrap. More...
 
static bool CastS32toU32 (int32_t op1, uint32_t *result)
 CERT INT30-C: Precondition test to ensure casting signed integer to unsigned integer do not wrap. More...
 
static bool CastS32toU16 (int32_t op1, uint16_t *result)
 CERT INT30-C: Precondition test to ensure casting signed integer to unsigned integer do not wrap. More...
 
static bool MultU64 (uint64_t op1, uint64_t op2, uint64_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap. More...
 
static bool MultS32 (int32_t op1, int32_t op2, int32_t *result)
 Precondition test to ensure that signed integer multiplication operation do not wrap. More...
 
static bool MultS64 (int64_t op1, int64_t op2, int64_t *result)
 CERT INT30-C Precondition test to ensure that signed integer multiplication operation do not wrap. More...
 
static bool SubU32 (uint32_t op1, uint32_t op2, uint32_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap. More...
 
static bool SubU16 (uint16_t op1, uint16_t op2, uint16_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap. More...
 
static bool SubS32 (int32_t op1, int32_t op2, int32_t *result)
 CERT INT32-C: Precondition test to ensure that signed integer subtraction operation does not overflow. More...
 
static bool SubU64 (uint64_t op1, uint64_t op2, uint64_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap. More...
 
static bool SubS64 (int64_t op1, int64_t op2, int64_t *result)
 CERT INT30-C Precondition test to ensure that signed integer subtraction operation do not wrap. More...
 
static bool SubSizet (size_t op1, size_t op2, size_t *result)
 CERT INT30-C: Precondition test to ensure that size_t subtraction operation do not wrap. More...
 
static void AddU16WithExit (uint16_t op1, uint16_t op2, uint16_t *result)
 Exit API is not supported in LK and BL. More...
 
static void AddU32WithExit (uint32_t op1, uint32_t op2, uint32_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap. More...
 
static void AddU64WithExit (uint64_t op1, uint64_t op2, uint64_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap. More...
 
static void AddU32UPTRWithExit (uintptr_t op1, uint32_t op2, uintptr_t *result)
 CERT INT30-C: Precondition test to ensure that uintptr_t and unsigned integer add operation do not wrap. More...
 
static void AddU32OffsetToVoidPtrWithExit (const void *op1, uint32_t op2, const void **result)
 CERT INT30-C: Precondition test to ensure that void * and unsigned integer add operation does not wrap. More...
 
static void AddUPTRSizetWithExit (uintptr_t op1, size_t op2, uintptr_t *result)
 CERT INT30-C: Precondition test to ensure that uintptr_t and size_t add operation do not wrap. More...
 
static void AddSizetWithExit (size_t op1, size_t op2, size_t *result)
 CERT INT30-C: Precondition test to ensure that size_t add operation do not wrap. More...
 
static void MultSizetWithExit (size_t op1, size_t op2, size_t *result)
 CERT INT30-C: Precondition test to ensure that size_t multiplication operation do not wrap. More...
 
static void AddU64UPTRWithExit (uintptr_t op1, uint64_t op2, uintptr_t *result)
 CERT INT30-C: Precondition test to ensure that uintptr_t unsigned integer add operation do not wrap Function calls NVOS_EXIT() on overflow. More...
 
static void MultU32WithExit (uint32_t op1, uint32_t op2, uint32_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap. More...
 
static void MultU64WithExit (uint64_t op1, uint64_t op2, uint64_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap. More...
 
static void SubU32WithExit (uint32_t op1, uint32_t op2, uint32_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap. More...
 
static void SubU64WithExit (uint64_t op1, uint64_t op2, uint64_t *result)
 CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap. More...
 
static void SubSizetWithExit (size_t op1, size_t op2, size_t *result)
 CERT INT30-C: Precondition test to ensure that size_t subtraction operation do not wrap. More...
 
static void AddS32WithExit (int32_t op1, int32_t op2, int32_t *result)
 CERT INT32-C: Precondition test to ensure that signed integer add operation do not overflow. More...
 
static void AddS64WithExit (int64_t op1, int64_t op2, int64_t *result)
 
static void SubS32WithExit (int32_t op1, int32_t op2, int32_t *result)
 CERT INT32-C: Precondition test to ensure that signed integer subtraction operation does not overflow. More...
 
static void SubS64WithExit (int64_t op1, int64_t op2, int64_t *result)
 
static void DivS32WithExit (int32_t op1, int32_t op2, int32_t *result)
 CERT INT32-C: Precondition test to ensure that signed integer division operation does not overflow or divide by zero. More...
 
static void DivS64WithExit (int64_t op1, int64_t op2, int64_t *result)
 
static uint32_t CastS32toU32WithExit (int32_t op)
 Casting functions to fix CERT INT31-C: Ensure integer conversions do not result in lost or misinterpreted data. More...
 
static int32_t CastU32toS32WithExit (uint32_t op)
 
static uint16_t CastU32toU16WithExit (uint32_t op)
 
static uint8_t CastU32toU8WithExit (uint32_t op)
 
static char CastU32toCharWithExit (uint32_t op)
 
static uint8_t CastU64toU8WithExit (uint64_t op)
 
static uint32_t CastU64toU32WithExit (uint64_t op)
 
static int32_t CastU64toS32WithExit (uint64_t op)
 
static uint32_t CastS64toU32WithExit (int64_t op)
 
static uint64_t CastS32toU64WithExit (int32_t op)
 
static uint8_t CastS32toU8WithExit (int32_t op)
 
static uint64_t CastS64toU64WithExit (int64_t op)
 
static int32_t CastS64toS32WithExit (int64_t op)
 
static int64_t CastU64toS64WithExit (uint64_t op)
 
static bool AddU32UPTR (uintptr_t op1, uint32_t op2, uintptr_t *result)
 CERT INT30-C: Ensure that uintptr_t and unsigned integer add do not result in lost or misinterpreted data. More...
 
static bool AddU32OffsetToVoidPtr (const void *op1, uint32_t op2, const void **result)
 CERT INT30-C: Ensure that adding a 32-bit integer offset to a void pointer does not result in integer overflow. More...
 
static bool NvConvertUint64toUint32 (uint64_t op, uint32_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertUint64toInt64 (uint64_t op, int64_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static void NvConvertUint32toInt64 (uint32_t op, int64_t *result)
 MISRA RULE 10.8 Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertUint32toUint16 (uint32_t op, uint16_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertUint32toInt32 (uint32_t op, int32_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertUint32toUint8 (uint32_t op, uint8_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertLint64toULint64 (int64_t op, uint64_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertLint64toUint32 (int64_t op, uint32_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertLint64toInt32 (int64_t op, int32_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static bool NvConvertInt32toUint32 (int32_t op, uint32_t *result)
 CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data. More...
 
static int32_t NvConvertFlagUInt32toInt32 (uint32_t flag_uint32)
 CERT INT30-C: Readl and writel APIs to avoid CERT-C warnings. More...
 
static uint32_t NvConvertFlagInt32toUInt32 (int32_t flag_int32)
 CERT INT31-C: More...
 
static bool ShiftLeftU32 (uint32_t operand, uint32_t shift, uint32_t *result)
 CERT INT34-C: More...
 
static bool ShiftRightU32 (uint32_t operand, uint32_t shift, uint32_t *result)
 CERT INT34-C: More...
 

Macro Definition Documentation

◆ ERR_INT30_C_ADDU16

#define ERR_INT30_C_ADDU16   0x378

Exit codes for function that call NVOS_EXIT().

Only LSBits are visible to parent process

Definition at line 210 of file nvos_static_analysis.h.

◆ ERR_INT30_C_ADDU32

#define ERR_INT30_C_ADDU32   0x377

Definition at line 211 of file nvos_static_analysis.h.

◆ ERR_INT30_C_ADDU32UPTR

#define ERR_INT30_C_ADDU32UPTR   0x34D

Definition at line 239 of file nvos_static_analysis.h.

◆ ERR_INT30_C_ADDU32VPTR

#define ERR_INT30_C_ADDU32VPTR   ERR_INT30_C_ADDU32UPTR

Definition at line 240 of file nvos_static_analysis.h.

◆ ERR_INT30_C_ADDU64

#define ERR_INT30_C_ADDU64   0x376

Definition at line 212 of file nvos_static_analysis.h.

◆ ERR_INT30_C_ADDU64UPTR

#define ERR_INT30_C_ADDU64UPTR   0x34E

Definition at line 238 of file nvos_static_analysis.h.

◆ ERR_INT30_C_MULTSIZET

#define ERR_INT30_C_MULTSIZET   0x34C

Definition at line 241 of file nvos_static_analysis.h.

◆ ERR_INT30_C_MULTU32

#define ERR_INT30_C_MULTU32   0x373

Definition at line 215 of file nvos_static_analysis.h.

◆ ERR_INT30_C_MULTU64

#define ERR_INT30_C_MULTU64   0x372

Definition at line 216 of file nvos_static_analysis.h.

◆ ERR_INT30_C_SUBU32

#define ERR_INT30_C_SUBU32   0x375

Definition at line 213 of file nvos_static_analysis.h.

◆ ERR_INT30_C_SUBU64

#define ERR_INT30_C_SUBU64   0x374

Definition at line 214 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_S32TOU32

#define ERR_INT31_C_CAST_S32TOU32   0x355

Definition at line 231 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_S32TOU64

#define ERR_INT31_C_CAST_S32TOU64   0x353

Definition at line 233 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_S32TOU8

#define ERR_INT31_C_CAST_S32TOU8   0x352

Definition at line 234 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_S64TOS32

#define ERR_INT31_C_CAST_S64TOS32   0x350

Definition at line 236 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_S64TOU32

#define ERR_INT31_C_CAST_S64TOU32   0x354

Definition at line 232 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_S64TOU64

#define ERR_INT31_C_CAST_S64TOU64   0x351

Definition at line 235 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U32TOS32

#define ERR_INT31_C_CAST_U32TOS32   0x360

Definition at line 226 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U32TOU16

#define ERR_INT31_C_CAST_U32TOU16   0x359

Definition at line 227 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U32TOU8

#define ERR_INT31_C_CAST_U32TOU8   0x358

Definition at line 228 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U64TOS32

#define ERR_INT31_C_CAST_U64TOS32   0x356

Definition at line 230 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U64TOS64

#define ERR_INT31_C_CAST_U64TOS64   0x34F

Definition at line 237 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U64TOU32

#define ERR_INT31_C_CAST_U64TOU32   0x357

Definition at line 229 of file nvos_static_analysis.h.

◆ ERR_INT31_C_CAST_U64TOU8

#define ERR_INT31_C_CAST_U64TOU8   0x361

Definition at line 225 of file nvos_static_analysis.h.

◆ ERR_INT32_C_ADDS32

#define ERR_INT32_C_ADDS32   0x371

Definition at line 217 of file nvos_static_analysis.h.

◆ ERR_INT32_C_ADDS64

#define ERR_INT32_C_ADDS64   0x370

Definition at line 218 of file nvos_static_analysis.h.

◆ ERR_INT32_C_DIVS32

#define ERR_INT32_C_DIVS32   0x365

Definition at line 223 of file nvos_static_analysis.h.

◆ ERR_INT32_C_DIVS64

#define ERR_INT32_C_DIVS64   0x364

Definition at line 224 of file nvos_static_analysis.h.

◆ ERR_INT32_C_MULTS32

#define ERR_INT32_C_MULTS32   0x367

Definition at line 221 of file nvos_static_analysis.h.

◆ ERR_INT32_C_MULTS64

#define ERR_INT32_C_MULTS64   0x366

Definition at line 222 of file nvos_static_analysis.h.

◆ ERR_INT32_C_SUBS32

#define ERR_INT32_C_SUBS32   0x369

Definition at line 219 of file nvos_static_analysis.h.

◆ ERR_INT32_C_SUBS64

#define ERR_INT32_C_SUBS64   0x368

Definition at line 220 of file nvos_static_analysis.h.

◆ NV_UINTPTR_MAX

#define NV_UINTPTR_MAX   ((uintptr_t)0U - 1U)

Define macro to replace uintptr_t max.

Definition at line 267 of file nvos_static_analysis.h.

◆ NvBoolFalse

#define NvBoolFalse   ((NvBoolVar)0x45450531U)

Define macro to replace boolean False.

Definition at line 261 of file nvos_static_analysis.h.

◆ NvBoolTrue

#define NvBoolTrue   ((NvBoolVar)0xBABAFACEU)

Define macro to replace boolean True.

Definition at line 254 of file nvos_static_analysis.h.

◆ NVOS_CERT

#define NVOS_CERT (   num)

Definition at line 197 of file nvos_static_analysis.h.

◆ NVOS_COV_PEND_WHITELIST

#define NVOS_COV_PEND_WHITELIST (   checker,
  comment_str 
)

Definition at line 202 of file nvos_static_analysis.h.

◆ NVOS_COV_STRING

#define NVOS_COV_STRING (   x)

Definition at line 198 of file nvos_static_analysis.h.

◆ NVOS_COV_WHITELIST

#define NVOS_COV_WHITELIST (   type,
  checker,
  comment_str 
)

Definition at line 199 of file nvos_static_analysis.h.

◆ NVOS_COV_WHITELIST_BLOCK_BEGIN

#define NVOS_COV_WHITELIST_BLOCK_BEGIN (   type,
  num,
  checker,
  comment_str 
)

Definition at line 200 of file nvos_static_analysis.h.

◆ NVOS_COV_WHITELIST_BLOCK_END

#define NVOS_COV_WHITELIST_BLOCK_END (   checker)

Definition at line 201 of file nvos_static_analysis.h.

◆ NVOS_EXIT

#define NVOS_EXIT (   x)    _exit(x)

Definition at line 39 of file nvos_static_analysis.h.

◆ NVOS_MISRA

#define NVOS_MISRA (   type,
  num 
)

These macros are used for whitelisting coverity violations.

The macros are only enabled when a coverity scan is being run. no-op macros for normal compilation - whitelisting is disabled when a coverity scan is NOT being run

Definition at line 196 of file nvos_static_analysis.h.

◆ OFFSET_MASK

#define OFFSET_MASK   0xFFFFUL

Definition at line 247 of file nvos_static_analysis.h.

◆ VA_ADDR_MASK

#define VA_ADDR_MASK   0xFFFFFFFFFFFFUL

Define macro for virtual address bit mask.

Definition at line 246 of file nvos_static_analysis.h.

Typedef Documentation

◆ NvBoolVar

typedef uint32_t NvBoolVar

Definition at line 249 of file nvos_static_analysis.h.

Function Documentation

◆ AddS32()

static bool AddS32 ( int32_t  op1,
int32_t  op2,
int32_t *  result 
)
inlinestatic

CERT INT30-C Precondition test to ensure that integer add operation do not wrap.

Definition at line 331 of file nvos_static_analysis.h.

◆ AddS32WithExit()

static void AddS32WithExit ( int32_t  op1,
int32_t  op2,
int32_t *  result 
)
inlinestatic

CERT INT32-C: Precondition test to ensure that signed integer add operation do not overflow.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 974 of file nvos_static_analysis.h.

References ERR_INT32_C_ADDS32, and NVOS_EXIT.

◆ AddS64()

static bool AddS64 ( int64_t  op1,
int64_t  op2,
int64_t *  result 
)
inlinestatic

CERT INT30-C Precondition test to ensure that integer add operation do not wrap.

Definition at line 362 of file nvos_static_analysis.h.

◆ AddS64WithExit()

static void AddS64WithExit ( int64_t  op1,
int64_t  op2,
int64_t *  result 
)
inlinestatic

Definition at line 985 of file nvos_static_analysis.h.

References ERR_INT32_C_ADDS64, and NVOS_EXIT.

◆ AddSizetWithExit()

static void AddSizetWithExit ( size_t  op1,
size_t  op2,
size_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that size_t add operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 834 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU32UPTR, and NVOS_EXIT.

◆ AddU16()

static bool AddU16 ( uint16_t  op1,
uint16_t  op2,
uint16_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap.

Definition at line 282 of file nvos_static_analysis.h.

◆ AddU16WithExit()

static void AddU16WithExit ( uint16_t  op1,
uint16_t  op2,
uint16_t *  result 
)
inlinestatic

Exit API is not supported in LK and BL.

CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap. Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 731 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU16, and NVOS_EXIT.

◆ AddU32()

static bool AddU32 ( uint32_t  op1,
uint32_t  op2,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap.

Definition at line 316 of file nvos_static_analysis.h.

◆ AddU32OffsetToVoidPtr()

static bool AddU32OffsetToVoidPtr ( const void *  op1,
uint32_t  op2,
const void **  result 
)
inlinestatic

CERT INT30-C: Ensure that adding a 32-bit integer offset to a void pointer does not result in integer overflow.

Definition at line 1208 of file nvos_static_analysis.h.

References NV_UINTPTR_MAX, NVOS_COV_WHITELIST, and NVOS_MISRA.

◆ AddU32OffsetToVoidPtrWithExit()

static void AddU32OffsetToVoidPtrWithExit ( const void *  op1,
uint32_t  op2,
const void **  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that void * and unsigned integer add operation does not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 797 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU32VPTR, NV_UINTPTR_MAX, NVOS_COV_WHITELIST, NVOS_EXIT, and NVOS_MISRA.

◆ AddU32UPTR()

static bool AddU32UPTR ( uintptr_t  op1,
uint32_t  op2,
uintptr_t *  result 
)
inlinestatic

CERT INT30-C: Ensure that uintptr_t and unsigned integer add do not result in lost or misinterpreted data.

Definition at line 1193 of file nvos_static_analysis.h.

References NV_UINTPTR_MAX.

◆ AddU32UPTRWithExit()

static void AddU32UPTRWithExit ( uintptr_t  op1,
uint32_t  op2,
uintptr_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that uintptr_t and unsigned integer add operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 780 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU32UPTR, NV_UINTPTR_MAX, and NVOS_EXIT.

◆ AddU32WithExit()

static void AddU32WithExit ( uint32_t  op1,
uint32_t  op2,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 747 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU32, and NVOS_EXIT.

◆ AddU64()

static bool AddU64 ( uint64_t  op1,
uint64_t  op2,
uint64_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap.

Definition at line 348 of file nvos_static_analysis.h.

◆ AddU64UPTRWithExit()

static void AddU64UPTRWithExit ( uintptr_t  op1,
uint64_t  op2,
uintptr_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that uintptr_t unsigned integer add operation do not wrap Function calls NVOS_EXIT() on overflow.

Only use when overflow cannot happen by design.

Definition at line 870 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU64UPTR, NV_UINTPTR_MAX, and NVOS_EXIT.

◆ AddU64WithExit()

static void AddU64WithExit ( uint64_t  op1,
uint64_t  op2,
uint64_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer add operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 763 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU64, and NVOS_EXIT.

◆ AddUPTRSizetWithExit()

static void AddUPTRSizetWithExit ( uintptr_t  op1,
size_t  op2,
uintptr_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that uintptr_t and size_t add operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 817 of file nvos_static_analysis.h.

References ERR_INT30_C_ADDU32UPTR, NV_UINTPTR_MAX, and NVOS_EXIT.

◆ CastS32toU16()

static bool CastS32toU16 ( int32_t  op1,
uint16_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure casting signed integer to unsigned integer do not wrap.

Definition at line 517 of file nvos_static_analysis.h.

◆ CastS32toU32()

static bool CastS32toU32 ( int32_t  op1,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure casting signed integer to unsigned integer do not wrap.

Definition at line 501 of file nvos_static_analysis.h.

◆ CastS32toU32WithExit()

static uint32_t CastS32toU32WithExit ( int32_t  op)
inlinestatic

Casting functions to fix CERT INT31-C: Ensure integer conversions do not result in lost or misinterpreted data.

Definition at line 1058 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_S32TOU32, and NVOS_EXIT.

◆ CastS32toU64WithExit()

static uint64_t CastS32toU64WithExit ( int32_t  op)
inlinestatic

Definition at line 1139 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_S32TOU64, and NVOS_EXIT.

◆ CastS32toU8WithExit()

static uint8_t CastS32toU8WithExit ( int32_t  op)
inlinestatic

Definition at line 1148 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_S32TOU8, and NVOS_EXIT.

◆ CastS64toS32WithExit()

static int32_t CastS64toS32WithExit ( int64_t  op)
inlinestatic

Definition at line 1166 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_S64TOS32, max, min, and NVOS_EXIT.

◆ CastS64toU32WithExit()

static uint32_t CastS64toU32WithExit ( int64_t  op)
inlinestatic

Definition at line 1130 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_S64TOU32, and NVOS_EXIT.

◆ CastS64toU64WithExit()

static uint64_t CastS64toU64WithExit ( int64_t  op)
inlinestatic

Definition at line 1157 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_S64TOU64, and NVOS_EXIT.

◆ CastU32toCharWithExit()

static char CastU32toCharWithExit ( uint32_t  op)
inlinestatic

Definition at line 1094 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U32TOU8, and NVOS_EXIT.

◆ CastU32toS32()

static bool CastU32toS32 ( uint32_t  op1,
int32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure casting unsigned integer to signed integer do not wrap.

Definition at line 485 of file nvos_static_analysis.h.

◆ CastU32toS32WithExit()

static int32_t CastU32toS32WithExit ( uint32_t  op)
inlinestatic

Definition at line 1067 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U32TOS32, and NVOS_EXIT.

◆ CastU32toU16WithExit()

static uint16_t CastU32toU16WithExit ( uint32_t  op)
inlinestatic

Definition at line 1076 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U32TOU16, and NVOS_EXIT.

◆ CastU32toU8WithExit()

static uint8_t CastU32toU8WithExit ( uint32_t  op)
inlinestatic

Definition at line 1085 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U32TOU8, and NVOS_EXIT.

◆ CastU64toS32()

static bool CastU64toS32 ( uint64_t  op1,
int32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure casting unsigned long to unsigned integer do not wrap.

Definition at line 469 of file nvos_static_analysis.h.

◆ CastU64toS32WithExit()

static int32_t CastU64toS32WithExit ( uint64_t  op)
inlinestatic

Definition at line 1121 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U64TOS32, and NVOS_EXIT.

◆ CastU64toS64WithExit()

static int64_t CastU64toS64WithExit ( uint64_t  op)
inlinestatic

Definition at line 1178 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U64TOS64, and NVOS_EXIT.

◆ CastU64toU32()

static bool CastU64toU32 ( uint64_t  op1,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure casting unsigned long to unsigned integer do not wrap.

Definition at line 427 of file nvos_static_analysis.h.

◆ CastU64toU32WithExit()

static uint32_t CastU64toU32WithExit ( uint64_t  op)
inlinestatic

Definition at line 1112 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U64TOU32, and NVOS_EXIT.

◆ CastU64toU8WithExit()

static uint8_t CastU64toU8WithExit ( uint64_t  op)
inlinestatic

Definition at line 1103 of file nvos_static_analysis.h.

References ERR_INT31_C_CAST_U64TOU8, and NVOS_EXIT.

◆ DivS32WithExit()

static void DivS32WithExit ( int32_t  op1,
int32_t  op2,
int32_t *  result 
)
inlinestatic

CERT INT32-C: Precondition test to ensure that signed integer division operation does not overflow or divide by zero.

Function calls NVOS_EXIT() on overflow or divide by zero. Only use when overflow/divide by zero cannot happen by design.

Definition at line 1034 of file nvos_static_analysis.h.

References ERR_INT32_C_DIVS32, and NVOS_EXIT.

◆ DivS64WithExit()

static void DivS64WithExit ( int64_t  op1,
int64_t  op2,
int64_t *  result 
)
inlinestatic

Definition at line 1044 of file nvos_static_analysis.h.

References ERR_INT32_C_DIVS64, and NVOS_EXIT.

◆ incrementUInt32()

static void incrementUInt32 ( uint32_t *  x)
inlinestatic

Increment uint32_t by one Precondition test to ensure value is within RANGE_MAX.

Definition at line 443 of file nvos_static_analysis.h.

◆ incrementUInt64()

static void incrementUInt64 ( uint64_t *  x)
inlinestatic

Increment uint64_t by one Precondition test to ensure value is within RANGE_MAX.

Definition at line 456 of file nvos_static_analysis.h.

◆ MultS32()

static bool MultS32 ( int32_t  op1,
int32_t  op2,
int32_t *  result 
)
inlinestatic

Precondition test to ensure that signed integer multiplication operation do not wrap.

Parameters
[in]op1Input operand to be Multiplied
[in]op2Value multiplied to input operand
[out]resultReference of variable to store product of two input operands
Returns
false if operation result wraps, else true.

Definition at line 562 of file nvos_static_analysis.h.

◆ MultS64()

static bool MultS64 ( int64_t  op1,
int64_t  op2,
int64_t *  result 
)
inlinestatic

CERT INT30-C Precondition test to ensure that signed integer multiplication operation do not wrap.

Definition at line 585 of file nvos_static_analysis.h.

◆ MultSizetWithExit()

static void MultSizetWithExit ( size_t  op1,
size_t  op2,
size_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that size_t multiplication operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 851 of file nvos_static_analysis.h.

References ERR_INT30_C_MULTSIZET, and NVOS_EXIT.

◆ MultU16()

static bool MultU16 ( uint16_t  op1,
uint16_t  op2,
uint16_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap.

Definition at line 402 of file nvos_static_analysis.h.

◆ MultU32()

static bool MultU32 ( uint32_t  op1,
uint32_t  op2,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap.

Definition at line 380 of file nvos_static_analysis.h.

◆ MultU32WithExit()

static void MultU32WithExit ( uint32_t  op1,
uint32_t  op2,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 886 of file nvos_static_analysis.h.

References ERR_INT30_C_MULTU32, and NVOS_EXIT.

◆ MultU64()

static bool MultU64 ( uint64_t  op1,
uint64_t  op2,
uint64_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap.

Definition at line 533 of file nvos_static_analysis.h.

◆ MultU64WithExit()

static void MultU64WithExit ( uint64_t  op1,
uint64_t  op2,
uint64_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer multiplication operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 905 of file nvos_static_analysis.h.

References ERR_INT30_C_MULTU64, and NVOS_EXIT.

◆ NvConvertFlagInt32toUInt32()

static uint32_t NvConvertFlagInt32toUInt32 ( int32_t  flag_int32)
inlinestatic

CERT INT31-C:

Convert Flags from Signed to Unsigned integer

Note:- NvConvertInt32toUint32() cannot be used for this purpose

Definition at line 1449 of file nvos_static_analysis.h.

References flag_converter::flag_int32, and flag_converter::flag_uint32.

◆ NvConvertFlagUInt32toInt32()

static int32_t NvConvertFlagUInt32toInt32 ( uint32_t  flag_uint32)
inlinestatic

CERT INT30-C: Readl and writel APIs to avoid CERT-C warnings.

CERT INT31-C:

Convert Flags from Unsigned to Signed integer

Note:- NvConvertUint32toInt32() cannot be used for this purpose

Definition at line 1433 of file nvos_static_analysis.h.

References flag_converter::flag_int32, and flag_converter::flag_uint32.

◆ NvConvertInt32toUint32()

static bool NvConvertInt32toUint32 ( int32_t  op,
uint32_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1361 of file nvos_static_analysis.h.

◆ NvConvertLint64toInt32()

static bool NvConvertLint64toInt32 ( int64_t  op,
int32_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1343 of file nvos_static_analysis.h.

References max, and min.

◆ NvConvertLint64toUint32()

static bool NvConvertLint64toUint32 ( int64_t  op,
uint32_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1327 of file nvos_static_analysis.h.

◆ NvConvertLint64toULint64()

static bool NvConvertLint64toULint64 ( int64_t  op,
uint64_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1311 of file nvos_static_analysis.h.

◆ NvConvertUint32toInt32()

static bool NvConvertUint32toInt32 ( uint32_t  op,
int32_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1279 of file nvos_static_analysis.h.

◆ NvConvertUint32toInt64()

static void NvConvertUint32toInt64 ( uint32_t  op,
int64_t *  result 
)
inlinestatic

MISRA RULE 10.8 Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1253 of file nvos_static_analysis.h.

◆ NvConvertUint32toUint16()

static bool NvConvertUint32toUint16 ( uint32_t  op,
uint16_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1263 of file nvos_static_analysis.h.

◆ NvConvertUint32toUint8()

static bool NvConvertUint32toUint8 ( uint32_t  op,
uint8_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1295 of file nvos_static_analysis.h.

◆ NvConvertUint64toInt64()

static bool NvConvertUint64toInt64 ( uint64_t  op,
int64_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1238 of file nvos_static_analysis.h.

◆ NvConvertUint64toUint32()

static bool NvConvertUint64toUint32 ( uint64_t  op,
uint32_t *  result 
)
inlinestatic

CERT INT31-C: Ensure that integer conversions do not result in lost or misinterpreted data.

Definition at line 1222 of file nvos_static_analysis.h.

◆ ShiftLeftU32()

static bool ShiftLeftU32 ( uint32_t  operand,
uint32_t  shift,
uint32_t *  result 
)
inlinestatic

CERT INT34-C:

Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand.

See: https://wiki.sei.cmu.edu/confluence/display/c/INT34-C.+Do+not+shift+an+expression+by+a+negative+number+of+bits+or+by+greater+than+or+equal+to+the+number+of+bits+that+exist+in+the+operand

Definition at line 1466 of file nvos_static_analysis.h.

◆ ShiftRightU32()

static bool ShiftRightU32 ( uint32_t  operand,
uint32_t  shift,
uint32_t *  result 
)
inlinestatic

CERT INT34-C:

Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand.

See: https://wiki.sei.cmu.edu/confluence/display/c/INT34-C.+Do+not+shift+an+expression+by+a+negative+number+of+bits+or+by+greater+than+or+equal+to+the+number+of+bits+that+exist+in+the+operand

Definition at line 1489 of file nvos_static_analysis.h.

◆ SubS32()

static bool SubS32 ( int32_t  op1,
int32_t  op2,
int32_t *  result 
)
inlinestatic

CERT INT32-C: Precondition test to ensure that signed integer subtraction operation does not overflow.

Definition at line 653 of file nvos_static_analysis.h.

◆ SubS32WithExit()

static void SubS32WithExit ( int32_t  op1,
int32_t  op2,
int32_t *  result 
)
inlinestatic

CERT INT32-C: Precondition test to ensure that signed integer subtraction operation does not overflow.

Function calls NVOS_EXIT() on overflow. Only use when overflow cannot happen by design.

Definition at line 1004 of file nvos_static_analysis.h.

References ERR_INT32_C_SUBS32, and NVOS_EXIT.

◆ SubS64()

static bool SubS64 ( int64_t  op1,
int64_t  op2,
int64_t *  result 
)
inlinestatic

CERT INT30-C Precondition test to ensure that signed integer subtraction operation do not wrap.

Definition at line 688 of file nvos_static_analysis.h.

◆ SubS64WithExit()

static void SubS64WithExit ( int64_t  op1,
int64_t  op2,
int64_t *  result 
)
inlinestatic

Definition at line 1015 of file nvos_static_analysis.h.

References ERR_INT32_C_SUBS64, and NVOS_EXIT.

◆ SubSizet()

static bool SubSizet ( size_t  op1,
size_t  op2,
size_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that size_t subtraction operation do not wrap.

Definition at line 708 of file nvos_static_analysis.h.

◆ SubSizetWithExit()

static void SubSizetWithExit ( size_t  op1,
size_t  op2,
size_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that size_t subtraction operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when underflow cannot happen by design.

Definition at line 958 of file nvos_static_analysis.h.

References ERR_INT30_C_SUBU64, and NVOS_EXIT.

◆ SubU16()

static bool SubU16 ( uint16_t  op1,
uint16_t  op2,
uint16_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap.

Definition at line 636 of file nvos_static_analysis.h.

◆ SubU32()

static bool SubU32 ( uint32_t  op1,
uint32_t  op2,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap.

Definition at line 620 of file nvos_static_analysis.h.

◆ SubU32WithExit()

static void SubU32WithExit ( uint32_t  op1,
uint32_t  op2,
uint32_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when underflow cannot happen by design.

Definition at line 924 of file nvos_static_analysis.h.

References ERR_INT30_C_SUBU32, and NVOS_EXIT.

◆ SubU64()

static bool SubU64 ( uint64_t  op1,
uint64_t  op2,
uint64_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap.

Definition at line 672 of file nvos_static_analysis.h.

◆ SubU64WithExit()

static void SubU64WithExit ( uint64_t  op1,
uint64_t  op2,
uint64_t *  result 
)
inlinestatic

CERT INT30-C: Precondition test to ensure that unsigned integer subtraction operation do not wrap.

Function calls NVOS_EXIT() on overflow. Only use when underflow cannot happen by design.

Definition at line 941 of file nvos_static_analysis.h.

References ERR_INT30_C_SUBU64, and NVOS_EXIT.