DTNMA Reference Tools v2.0.0 - 7.g88e232c
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
Loading...
Searching...
No Matches
defs.h File Reference

This file contains preprocessor utility definitions shared among the ARI library. More...

Macros

#define _U_
 Mark an unused parameter Within a function definition.
 
#define UNLIKELY(expr)   (expr)
 
#define LIKELY(expr)   (expr)
 
#define CHKRET(cond, val)
 Check a condition and if not met return a specific value.
 
#define CHKVOID(cond)   CHKRET(cond, )
 Return from void functions if condition fails.
 
#define CHKNULL(cond)   CHKRET(cond, NULL)
 Return a null pointer if condition fails.
 
#define CHKFALSE(cond)   CHKRET(cond, false)
 Return false if condition fails.
 
#define CHKERR1(cond)   CHKRET(cond, 1)
 Return the error value 1 if condition fails.
 
#define CHKERRVAL(value)   CHKRET(!value, value)
 Check a value for non-zero and return that value.
 

Detailed Description

This file contains preprocessor utility definitions shared among the ARI library.

Macro Definition Documentation

◆ _U_

#define _U_

Mark an unused parameter Within a function definition.

This avoids compiler warnings when parameters need to be present to satisfy an interface but are otherwise unused.

◆ CHKERRVAL

#define CHKERRVAL (   value)    CHKRET(!value, value)

Check a value for non-zero and return that value.

Warning
The parameter is evaluated twice so should be a simple variable.
Parameters
valueThe value to check and conditionally return.

◆ CHKRET

#define CHKRET (   cond,
  val 
)
Value:
if (!LIKELY(cond)) \
{ \
return val; \
}

Check a condition and if not met return a specific value.

Parameters
condThe condition to check.
valThe return value if the check fails.