OSVR-Core
Macros
Static analysis annotation macros

Wrappers for Microsoft's SAL annotations and othersUse of these is optional, but recommended particularly for C APIs, as well as any methods handling a buffer with a length. More...

Macros

#define OSVR_RETURN_SUCCESS_CONDITION(X)
 Applied to a typedef, indicates the condition for return under which a function returning it should be considered to have succeeded (thus holding certain specifications). More...
 

Parameter annotations

These indicate the role and valid values for parameters to functions.

At most one of these should be placed before a parameter's type name in the function parameter list, in both the declaration and definition. (They must match!)

#define OSVR_IN
 Indicates a required function parameter that serves only as input.
 
#define OSVR_IN_PTR
 Indicates a required pointer (non-null) function parameter that serves only as input.
 
#define OSVR_IN_OPT
 Indicates a function parameter (pointer) that serves only as input, but is optional and might be NULL.
 
#define OSVR_IN_STRZ
 Indicates a null-terminated string function parameter that serves only as input.
 
#define OSVR_IN_READS(NUM_ELEMENTS)
 Indicates a buffer containing input with the specified number of elements. More...
 
#define OSVR_OUT
 Indicates a required function parameter that serves only as output. More...
 
#define OSVR_OUT_PTR
 Indicates a required pointer (non-null) function parameter that serves only as output.
 
#define OSVR_OUT_OPT
 Indicates a function parameter (pointer) that serves only as output, but is optional and might be NULL.
 
#define OSVR_INOUT
 Indicates a required function parameter that is both read and written to. More...
 
#define OSVR_INOUT_PTR
 Indicates a required pointer (non-null) function parameter that is both read and written to.
 

Function annotations

These indicate particular relevant aspects about a function.

Some duplicate the effective meaning of parameter annotations: applying both allows the fullest extent of static analysis tools to analyze the code, and in some compilers, generate warnings.

#define OSVR_FUNC_NONNULL(X)
 Indicates the parameter(s) that must be non-null. More...
 
#define OSVR_RETURN_WARN_UNUSED
 Indicates the function has a return value that must be used (either a security problem or an obvious bug if not). More...
 

Detailed Description

Wrappers for Microsoft's SAL annotations and others

Use of these is optional, but recommended particularly for C APIs, as well as any methods handling a buffer with a length.

Macro Definition Documentation

§ OSVR_FUNC_NONNULL

#define OSVR_FUNC_NONNULL (   X)

Indicates the parameter(s) that must be non-null.

Parameters
XA parenthesized list of parameters by number (1-based index)

Should be placed after a function declaration (but before the semicolon). Repeating in the definition is not needed.

§ OSVR_IN_READS

#define OSVR_IN_READS (   NUM_ELEMENTS)

Indicates a buffer containing input with the specified number of elements.

The specified number of elements is typically the name of another parameter.

§ OSVR_INOUT

#define OSVR_INOUT

Indicates a required function parameter that is both read and written to.

In C code, since this usually means "pointer", you probably want OSVR_INOUT_PTR instead.

§ OSVR_OUT

#define OSVR_OUT

Indicates a required function parameter that serves only as output.

In C code, since this usually means "pointer", you probably want OSVR_OUT_PTR instead.

§ OSVR_RETURN_SUCCESS_CONDITION

#define OSVR_RETURN_SUCCESS_CONDITION (   X)

Applied to a typedef, indicates the condition for return under which a function returning it should be considered to have succeeded (thus holding certain specifications).

Should be placed before the typename in a typedef, with the parameter including the keyword return to substitute for the return value.

§ OSVR_RETURN_WARN_UNUSED

#define OSVR_RETURN_WARN_UNUSED

Indicates the function has a return value that must be used (either a security problem or an obvious bug if not).

Should be placed before the return value (and virtual keyword, if applicable) in both declaration and definition.