QH_RET_ON_ERRNO()

Updated: April 19, 2023

A macro that conditionally (if not EOK) sets errno and returns the specified error

Synopsis:

#include <qh/error.h>
#define QH_RET_ON_ERRNO(errno)

Arguments:

errno
The standard errno to set errno to (if not EOK) and then return with.

Library:

qh

Description:

If the errno passed in is not EOK, errno is set to it, and then the pre-evaluated value of errno is returned. If errno evaluates to EOK, errno is not set and the macro does not call return.

Because this is a macro that conditionally calls return, the invoking function may actually return when the macro is executed. The invoking function is expected to have an int as its return type.

Because what is passed in to the macro is only evaluated once, it is safe to execute operations as part of calling the macro.