diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2021-03-28 04:30:11 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-04-16 20:05:17 +0200 |
commit | ad16e351773f4b606dd8b4dbbe77c2cb35bf5133 (patch) | |
tree | eca8c3a58a2b548032d17aae710daaf6d65d283d /proto/bmp/utils.h | |
parent | a848dad40aa618e5e24417e4ef46b62c860de679 (diff) |
BMP: Remove superfluous error handling
Most error handling code was was for cases that cannot happen,
or they would be code bugs (and should use ASSERT()). Keep error
handling for just for I/O errors, like in rest of BIRD.
Diffstat (limited to 'proto/bmp/utils.h')
-rw-r--r-- | proto/bmp/utils.h | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/proto/bmp/utils.h b/proto/bmp/utils.h deleted file mode 100644 index faca2ba0..00000000 --- a/proto/bmp/utils.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * BIRD -- The BGP Monitoring Protocol (BMP) - * - * (c) 2020 Akamai Technologies, Inc. (Pawel Maslanka, pmaslank@akamai.com) - * - * Can be freely distributed and used under the terms of the GNU GPL. - */ - -#ifndef _BIRD_BMP_UTILS_H_ -#define _BIRD_BMP_UTILS_H_ - -/** - * TODO: - * - Provide descriptive explanation for the follwing enums - */ -enum bmp_result { - BMP_E_NONE = 0, - BMP_E_INVALID_ARG, - BMP_E_NULL_REF, - BMP_E_EXISTS, - BMP_E_NOT_EXISTS, - BMP_E_OPEN_SOCKET, - BMP_E_CONNECT_TO_SRV, - BMP_E_SEND_DATA, - BMP_E_BIRDSOCK_NULL_REF, - BMP_E_REMOTE_CAPS_NULL_REF, - BMP_E_NEW_TX_EVENT -}; - -#define BMP_FAILED(v) \ - (v != BMP_E_NONE) - -#define IF_BMP_FAILED_RETURN_RC(func) \ - do { \ - enum bmp_result rc = func; \ - if (BMP_FAILED(rc)) \ - { \ - return rc; \ - } \ - } while (0) - -// The following macro requires to define locally enum bmp_result rc; -#define IF_BMP_FAILED_GOTO_LABEL(func, label) \ - do { \ - rc = func; \ - if (BMP_FAILED(rc)) \ - { \ - goto label; \ - } \ - } while (0) - -#define IF_BMP_FAILED_PRINT_ERR_MSG(func, msg) \ - do { \ - enum bmp_result rc = func; \ - if (BMP_FAILED(rc)) \ - { \ - log(L_WARN "[BMP] " msg " (rc = %d)", rc); \ - } \ - } while (0) - -#define IF_BMP_FAILED_PRINT_ERR_MSG_AND_GOTO_LABEL(func, msg, label) \ - do { \ - enum bmp_result rc = func; \ - if (BMP_FAILED(rc)) \ - { \ - log(L_WARN "[BMP] " msg " (rc = %d)", rc); \ - goto label; \ - } \ - } while (0) - -#define IS_NULL(ptr) \ - ((ptr) == NULL) - -#define IF_COND_TRUE_PRINT_ERR_MSG_AND_RETURN_OPT_VAL(expr, msg, rv...) \ - do { \ - if ((expr)) \ - { \ - log(L_WARN "[BMP] " msg); \ - return rv; \ - } \ - } while (0) - -#define IF_PTR_IS_NULL_PRINT_ERR_MSG_AND_RETURN_OPT_VAL(p, msg, rv...) \ - do { \ - IF_COND_TRUE_PRINT_ERR_MSG_AND_RETURN_OPT_VAL(IS_NULL(p), msg, rv); \ - } while (0) - -#define IF_BMP_FAILED_PRINT_ERR_MSG_AND_RETURN_OPT_VAL(func, msg, rv...) \ - do { \ - enum bmp_result rc = func; \ - IF_COND_TRUE_PRINT_ERR_MSG_AND_RETURN_OPT_VAL(BMP_FAILED(rc), msg, rv); \ - } while (0) - -#endif /* _BIRD_BMP_UTILS_H_ */
\ No newline at end of file |