Clean up return code types

* Remove dds_return_t / dds_retcode_t distinction (now there is only
  dds_return_t and all error codes are always negative)

* Remove Q_ERR_... error codes and replace them by DDS_RETCODE_...
  ones so that there is only one set of error codes

* Replace a whole bunch "int" return types that were used to return
  Q_ERR_... codes by "dds_return_t" return types

Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
Erik Boasson 2019-05-23 16:51:43 +02:00 committed by eboasson
parent a652ecb78e
commit 19aec98b8a
126 changed files with 1565 additions and 1722 deletions

View file

@ -30,7 +30,7 @@ extern "C" {
* byte), or would have been written would @buf have been
* sufficiently large enough.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Environment variable written to @buf.
@ -43,7 +43,7 @@ extern "C" {
* @retval DDS_RETCODE_ERROR
* Unspecified error.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_getenv(
const char *name,
char **value)
@ -58,7 +58,7 @@ ddsrt_nonnull_all;
* @param[in] name Environment variable name.
* @param[in] value Value to set environment variable to.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Environment variable successfully set to @value.
@ -69,7 +69,7 @@ ddsrt_nonnull_all;
* @retval DDS_RETCODE_ERROR
* Unspecified system error.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_setenv(
const char *name,
const char *value)
@ -80,7 +80,7 @@ ddsrt_nonnull_all;
*
* @param[in] name Environment variable name.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Environment variable successfully unset.
@ -91,7 +91,7 @@ ddsrt_nonnull_all;
* @retval DDS_RETCODE_ERROR
* Unspecified system error.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_unsetenv(
const char *name)
ddsrt_nonnull_all;

View file

@ -30,7 +30,7 @@ struct ddsrt_ifaddrs {
typedef struct ddsrt_ifaddrs ddsrt_ifaddrs_t;
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_getifaddrs(
ddsrt_ifaddrs_t **ifap,
const int *afs);

View file

@ -72,7 +72,7 @@ ddsrt_getpid(void);
* @param[in] argv Arguments array.
* @param[out] pid ID of the created process.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Process successfully created.
@ -85,7 +85,7 @@ ddsrt_getpid(void);
* @retval DDS_RETCODE_ERROR
* Process could not be created.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_proc_create(
const char *executable,
char *const argv[],
@ -109,7 +109,7 @@ ddsrt_proc_create(
* @param[in] timemout Time within the process is expected to finish.
* @param[out] code The exit code of the process.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Process has terminated and its exit code has been captured.
@ -124,7 +124,7 @@ ddsrt_proc_create(
* @retval DDS_RETCODE_ERROR
* Getting the exit code failed for an unknown reason.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_proc_waitpid(
ddsrt_pid_t pid,
dds_duration_t timeout,
@ -149,7 +149,7 @@ ddsrt_proc_waitpid(
* @param[out] pid Process ID (PID) of the finished process.
* @param[out] code The exit code of the process.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* A process has terminated.
@ -165,7 +165,7 @@ ddsrt_proc_waitpid(
* @retval DDS_RETCODE_ERROR
* Getting the exit code failed for an unknown reason.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_proc_waitpids(
dds_duration_t timeout,
ddsrt_pid_t *pid,
@ -176,7 +176,7 @@ ddsrt_proc_waitpids(
*
* @param[in] pid Process ID (PID) to check if it exists.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* The process exists.
@ -185,7 +185,7 @@ ddsrt_proc_waitpids(
* @retval DDS_RETCODE_ERROR
* Determining if a process exists or not, failed.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_proc_exists(
ddsrt_pid_t pid);
@ -202,7 +202,7 @@ ddsrt_proc_exists(
*
* @param[in] pid Process ID (PID) of the process to terminate.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Kill attempt has been started.
@ -213,7 +213,7 @@ ddsrt_proc_exists(
* @retval DDS_RETCODE_ERROR
* Kill failed for an unknown reason.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_proc_kill(
ddsrt_pid_t pid);

View file

@ -9,7 +9,7 @@
extern "C" {
#endif
typedef int32_t dds_retcode_t;
typedef int32_t dds_return_t;
/*
State is unchanged following a function call returning an error
@ -29,25 +29,25 @@ typedef int32_t dds_retcode_t;
* @{
*/
#define DDS_RETCODE_OK 0 /**< Success */
#define DDS_RETCODE_ERROR 1 /**< Non specific error */
#define DDS_RETCODE_UNSUPPORTED 2 /**< Feature unsupported */
#define DDS_RETCODE_BAD_PARAMETER 3 /**< Bad parameter value */
#define DDS_RETCODE_PRECONDITION_NOT_MET 4 /**< Precondition for operation not met */
#define DDS_RETCODE_OUT_OF_RESOURCES 5 /**< When an operation fails because of a lack of resources */
#define DDS_RETCODE_NOT_ENABLED 6 /**< When a configurable feature is not enabled */
#define DDS_RETCODE_IMMUTABLE_POLICY 7 /**< When an attempt is made to modify an immutable policy */
#define DDS_RETCODE_INCONSISTENT_POLICY 8 /**< When a policy is used with inconsistent values */
#define DDS_RETCODE_ALREADY_DELETED 9 /**< When an attempt is made to delete something more than once */
#define DDS_RETCODE_TIMEOUT 10 /**< When a timeout has occurred */
#define DDS_RETCODE_NO_DATA 11 /**< When expected data is not provided */
#define DDS_RETCODE_ILLEGAL_OPERATION 12 /**< When a function is called when it should not be */
#define DDS_RETCODE_NOT_ALLOWED_BY_SECURITY 13 /**< When credentials are not enough to use the function */
#define DDS_RETCODE_ERROR -1 /**< Non specific error */
#define DDS_RETCODE_UNSUPPORTED -2 /**< Feature unsupported */
#define DDS_RETCODE_BAD_PARAMETER -3 /**< Bad parameter value */
#define DDS_RETCODE_PRECONDITION_NOT_MET -4 /**< Precondition for operation not met */
#define DDS_RETCODE_OUT_OF_RESOURCES -5 /**< When an operation fails because of a lack of resources */
#define DDS_RETCODE_NOT_ENABLED -6 /**< When a configurable feature is not enabled */
#define DDS_RETCODE_IMMUTABLE_POLICY -7 /**< When an attempt is made to modify an immutable policy */
#define DDS_RETCODE_INCONSISTENT_POLICY -8 /**< When a policy is used with inconsistent values */
#define DDS_RETCODE_ALREADY_DELETED -9 /**< When an attempt is made to delete something more than once */
#define DDS_RETCODE_TIMEOUT -10 /**< When a timeout has occurred */
#define DDS_RETCODE_NO_DATA -11 /**< When expected data is not provided */
#define DDS_RETCODE_ILLEGAL_OPERATION -12 /**< When a function is called when it should not be */
#define DDS_RETCODE_NOT_ALLOWED_BY_SECURITY -13 /**< When credentials are not enough to use the function */
/* Extended return codes are not in the DDS specification and are meant
exclusively for internal use and must not be returned by the C API. */
#define DDS_XRETCODE_BASE (50)
#define DDS_XRETCODE(x) (DDS_XRETCODE_BASE + (x))
#define DDS_XRETCODE_BASE (-50)
#define DDS_XRETCODE(x) (DDS_XRETCODE_BASE - (x))
/** Requested resource is busy */
#define DDS_RETCODE_IN_PROGRESS DDS_XRETCODE(1)
@ -88,7 +88,7 @@ typedef int32_t dds_retcode_t;
*
* @returns String corresponding to the error value
*/
DDS_EXPORT const char *dds_strretcode(dds_retcode_t ret);
DDS_EXPORT const char *dds_strretcode(dds_return_t ret);
#if defined (__cplusplus)
}

View file

@ -52,7 +52,7 @@ typedef struct {
* @param[in] who DDSRT_RUSAGE_SELF or DDSRT_RUSAGE_THREAD.
* @param[in] usage Structure where resource usage is returned.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Resource usage successfully returned in @usage.
@ -61,7 +61,7 @@ typedef struct {
* @retval DDS_RETCODE_ERROR
* An unidentified error occurred.
*/
DDS_EXPORT dds_retcode_t ddsrt_getrusage(int who, ddsrt_rusage_t *usage);
DDS_EXPORT dds_return_t ddsrt_getrusage(int who, ddsrt_rusage_t *usage);
#if defined (__cplusplus)
}

View file

@ -32,53 +32,53 @@ extern const struct in6_addr ddsrt_in6addr_loopback;
#define DDSRT_AF_TERM (-1)
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_gethostname(
char *hostname,
size_t buffersize);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_socket(
ddsrt_socket_t *sockptr,
int domain,
int type,
int protocol);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_close(
ddsrt_socket_t sock);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_connect(
ddsrt_socket_t sock,
const struct sockaddr *addr,
socklen_t addrlen);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_accept(
ddsrt_socket_t sock,
struct sockaddr *addr,
socklen_t *addrlen,
ddsrt_socket_t *connptr);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_listen(
ddsrt_socket_t sock,
int backlog);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_bind(
ddsrt_socket_t sock,
const struct sockaddr *addr,
socklen_t addrlen);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_getsockname(
ddsrt_socket_t sock,
struct sockaddr *addr,
socklen_t *addrlen);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_send(
ddsrt_socket_t sock,
const void *buf,
@ -86,14 +86,14 @@ ddsrt_send(
int flags,
ssize_t *sent);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_sendmsg(
ddsrt_socket_t sock,
const ddsrt_msghdr_t *msg,
int flags,
ssize_t *sent);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_recv(
ddsrt_socket_t sock,
void *buf,
@ -101,14 +101,14 @@ ddsrt_recv(
int flags,
ssize_t *rcvd);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_recvmsg(
ddsrt_socket_t sock,
ddsrt_msghdr_t *msg,
int flags,
ssize_t *rcvd);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_getsockopt(
ddsrt_socket_t sock,
int32_t level, /* SOL_SOCKET */
@ -116,7 +116,7 @@ ddsrt_getsockopt(
void *optval,
socklen_t *optlen);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_setsockopt(
ddsrt_socket_t sock,
int32_t level, /* SOL_SOCKET */
@ -130,7 +130,7 @@ ddsrt_setsockopt(
* @param[in] sock Socket to set I/O mode for.
* @param[in] nonblock true for nonblocking, or false for blocking I/O.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* I/O mode successfully set to (non)blocking.
@ -141,7 +141,7 @@ ddsrt_setsockopt(
* @retval DDS_RETCODE_ERROR
* An unknown error error occurred.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_setsocknonblocking(
ddsrt_socket_t sock,
bool nonblock);
@ -228,11 +228,11 @@ ddsrt_sockaddr_insamesubnet(
const struct sockaddr *mask)
ddsrt_nonnull_all;
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_sockaddrfromstr(
int af, const char *str, void *sa);
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_sockaddrtostr(
const void *sa, char *buf, size_t size);
@ -249,7 +249,7 @@ typedef struct {
* @param[in] af Address family, either AF_INET, AF_INET6 or AF_UNSPEC.
* @param[out] hent Structure of type ddsrt_hostent_t.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Host name successfully resolved to address(es).
@ -262,7 +262,7 @@ typedef struct {
* @retval DDS_RETCODE_TRY_AGAIN
* Nonauthoratitative host not found.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_gethostbyname(
const char *name,
int af,

View file

@ -176,7 +176,7 @@ ddsrt_nonnull((1,2));
* @param[in] buf Buffer where description is copied to.
* @param[in] buflen Number of bytes available in @buf.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Description for @errnum was successfully copied to @buf.
@ -185,7 +185,7 @@ ddsrt_nonnull((1,2));
* @retval DDS_RETCODE_NOT_ENOUGH_SPACE
* Buffer was not large enough to hold the description.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_strerror_r(
int errnum,
char *buf,

View file

@ -34,9 +34,9 @@ extern "C" {
* character is stored.
* @param[out] dblptr A double where the result is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_strtod(const char *nptr, char **endptr, double *dblptr);
/**
@ -47,9 +47,9 @@ ddsrt_strtod(const char *nptr, char **endptr, double *dblptr);
* character is stored.
* @param[out] fltptr A float where the floating-point number is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_strtof(const char *nptr, char **endptr, float *fltptr);
/**

View file

@ -37,7 +37,7 @@ extern "C" {
* determine from @str.
* @param[out] llng A long long integer where the number is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* String successfully converted to an integer.
@ -46,7 +46,7 @@ extern "C" {
* @retval DDS_RETCODE_OUT_OF_RANGE
* String converted to an integer, but was out of range.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_strtoll(
const char *str,
char **endptr,
@ -69,7 +69,7 @@ ddsrt_strtoll(
* determine from @str.
* @param[out] ullng A long long integer where the number is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* String successfully converted to an integer.
@ -78,7 +78,7 @@ ddsrt_strtoll(
* @retval DDS_RETCODE_OUT_OF_RANGE
* String converted to an integer, but was out of range.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_strtoull(
const char *str,
char **endptr,
@ -91,7 +91,7 @@ ddsrt_strtoull(
* @param[in] str String to convert into a long long integer.
* @param[in] llng A long long integer where the number is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* String successfully converted to an integer.
@ -100,7 +100,7 @@ ddsrt_strtoull(
* @retval DDS_RETCODE_OUT_OF_RANGE
* String converted to an integer, but was out of range.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_atoll(
const char *str,
long long *llng);
@ -111,7 +111,7 @@ ddsrt_atoll(
* @param[in] str String to conver into an unsigned long long integer.
* @param[out] ullng An unsigned long long integer where the number is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* String successfully converted to an integer.
@ -120,7 +120,7 @@ ddsrt_atoll(
* @retval DDS_RETCODE_OUT_OF_RANGE
* String converted to an integer, but was out of range.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_atoull(
const char *str,
unsigned long long *ullng);

View file

@ -55,7 +55,7 @@ DDS_EXPORT void ddsrt_thread_pool_purge (ddsrt_thread_pool pool);
Note that if the pool queue has reached it's maximum DDS_RETCODE_TRY_AGAIN is returned.
*/
DDS_EXPORT dds_retcode_t ddsrt_thread_pool_submit
DDS_EXPORT dds_return_t ddsrt_thread_pool_submit
(
ddsrt_thread_pool pool, /* Thread pool instance */
void (*fn) (void *arg), /* Function to be invoked by thread from pool */

View file

@ -121,14 +121,14 @@ ddsrt_nonnull_all;
* @param[in] start_routine Function to execute in created thread.
* @param[in] arg Argument passed to @start_routine.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Thread successfully created.
* @retval DDS_RETCODE_ERROR
* Thread could not be created.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_thread_create(
ddsrt_thread_t *thread,
const char *name,
@ -172,14 +172,14 @@ ddsrt_thread_equal(ddsrt_thread_t t1, ddsrt_thread_t t2);
* @param[in] thread Id of thread to wait for.
* @param[out] thread_result Location where thread result is stored.
*
* @returns A dds_retcode_t indicating success or failure.
* @returns A dds_return_t indicating success or failure.
*
* @retval DDS_RETCODE_OK
* Target thread terminated.
* @retval DDS_RETCODE_ERROR
* An error occurred while waiting for the thread to terminate.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_thread_join(
ddsrt_thread_t thread,
uint32_t *thread_result);
@ -224,7 +224,7 @@ ddsrt_thread_setname(
* @param[in] routine Cleanup handler to push onto the thread cleanup stack.
* @param[in] arg Argument that will be passed to the cleanup handler.
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_thread_cleanup_push(
void (*routine)(void*),
void *arg);
@ -235,7 +235,7 @@ ddsrt_thread_cleanup_push(
* Remove routine at the top of the calling thread's cleanup stack and
* optionally invoke it (if execute is non-zero).
*/
DDS_EXPORT dds_retcode_t
DDS_EXPORT dds_return_t
ddsrt_thread_cleanup_pop(
int execute);