#include <ws_symbol_export.h>
#include <ws_attributes.h>
#include <stdbool.h>
#include <string.h>
#include <wsutil/wslog.h>
#include <wsutil/wmem/wmem.h>
Go to the source code of this file.
|
#define | WS_ASSERT_ENABLED 1 |
|
#define | ws_assert_if_active(active, expr) |
|
#define | ws_abort_if_fail(expr) ws_assert_if_active(true, expr) |
|
#define | ws_assert(expr) ws_assert_if_active(WS_ASSERT_ENABLED, expr) |
|
#define | ws_assert_streq(s1, s2) ws_assert((s1) && (s2) && strcmp((s1), (s2)) == 0) |
|
#define | ws_assert_utf8(str, len) |
|
#define | ws_assert_not_reached() ws_error("assertion \"not reached\" failed") |
|
#define | ws_warn_badarg(str) |
|
#define | ws_return_str_if(expr, scope) |
|
#define | ws_return_val_if(expr, val) |
|
Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs
SPDX-License-Identifier: GPL-2.0-or-later
◆ ws_assert_if_active
#define ws_assert_if_active |
( |
|
active, |
|
|
|
expr |
|
) |
| |
Value: do { \
if ((active) && !(expr)) \
ws_error("assertion failed: %s", #expr); \
} while (0)
◆ ws_assert_utf8
#define ws_assert_utf8 |
( |
|
str, |
|
|
|
len |
|
) |
| |
Value: do { \
const char *__assert_endptr; \
if (WS_ASSERT_ENABLED && \
!g_utf8_validate(str, len, &__assert_endptr)) { \
ws_log_utf8_full(LOG_DOMAIN_UTF_8, LOG_LEVEL_ERROR, \
__FILE__, __LINE__, __func__, \
str, len, __assert_endptr); \
} \
} while (0)
◆ ws_return_str_if
#define ws_return_str_if |
( |
|
expr, |
|
|
|
scope |
|
) |
| |
Value: do { \
if (WS_ASSERT_ENABLED && (expr)) { \
ws_warn_badarg(#expr); \
return wmem_strdup_printf(scope, "(invalid argument: %s)", #expr); \
} \
} while (0)
◆ ws_return_val_if
#define ws_return_val_if |
( |
|
expr, |
|
|
|
val |
|
) |
| |
Value: do { \
if (WS_ASSERT_ENABLED && (expr)) { \
ws_warn_badarg(#expr); \
return (val); \
} \
} while (0)
◆ ws_warn_badarg
#define ws_warn_badarg |
( |
|
str | ) |
|
Value: ws_log_full(LOG_DOMAIN_EINVAL, LOG_LEVEL_WARNING, \
__FILE__, __LINE__, __func__, \
"invalid argument: %s", str)