hamnet70/impl/src/results.h

53 lines
1.6 KiB
C
Raw Normal View History

/*
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Copyright (C) 2024 Thomas Kolb
*/
2022-02-27 16:02:51 +01:00
#ifndef RESULTS_H
#define RESULTS_H
2024-05-30 10:44:42 +02:00
#include "logger.h"
typedef enum {
OK,
ERR_INVALID_STATE, // module or context is in an invalid state
ERR_INVALID_PARAM, // invalid / nonsense parameters given
ERR_INVALID_ADDRESS, // invalid address received or given
ERR_NO_MEM, // not enough memory or allocation error
ERR_SIZE, // a given size is invalid
ERR_LIQUID, // an error occurred in the LiquidDSP library.
ERR_SYSCALL, // a syscall failed. Use errno to determine the cause.
ERR_SOAPY, // an error occurred in the SoapySDR library.
ERR_SDR, // an error occurred in the SDR interface.
ERR_INTEGRITY, // an integrity check failed (e.g. CRC of received packet is wrong)
ERR_SEQUENCE, // an unexpected packet was received
} result_t;
#ifdef DEBUG_LIQUID
#include <liquid/liquid.h>
#define ERR_CHECK_LIQUID(call) \
do { \
liquid_error_code lq_result; \
if((lq_result = (call)) != LIQUID_OK) { \
2024-05-30 10:44:42 +02:00
LOG(LVL_ERR, "Liquid call failed in %s:%d: %s", __FILE__, __LINE__, liquid_error_info(lq_result)); \
return ERR_LIQUID; \
} \
} while(0);
#else
# define ERR_CHECK_LIQUID(call) if((call) != LIQUID_OK) { return ERR_LIQUID; }
#endif
#define ERR_CHECK(call) \
do { \
result_t err_check_result = call; \
if(err_check_result != OK) { \
2024-05-30 10:44:42 +02:00
LOG(LVL_ERR, "Error detected at %s:%d: %d", __FILE__, __LINE__, err_check_result); \
return err_check_result; \
} \
} while(0);
2022-02-27 16:02:51 +01:00
#endif // RESULTS_H