mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 08:56:15 +09:00
ASSERT_PTR() and friends in assert-fundamental.h make use of assert() and assert_se() which when not building for sd-boot are defined in assert-util.h. Because assert() from glibc is only overridden in assert-util.h, the macros in assert-fundamental.h still end up using the glibc assert. Let's fix this by moving the required macros and related logic to assert-fundamental.h.
31 lines
1.3 KiB
C
31 lines
1.3 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
#pragma once
|
|
|
|
#include "assert-fundamental.h"
|
|
#include "macro.h"
|
|
|
|
/* Logging for various assertions */
|
|
|
|
void log_set_assert_return_is_critical(bool b);
|
|
bool log_get_assert_return_is_critical(void) _pure_;
|
|
|
|
void log_assert_failed_return(const char *text, const char *file, int line, const char *func);
|
|
|
|
#define assert_log(expr, message) ((_likely_(expr)) \
|
|
? (true) \
|
|
: (log_assert_failed_return(message, PROJECT_FILE, __LINE__, __func__), false))
|
|
|
|
#define assert_return(expr, r) \
|
|
do { \
|
|
if (!assert_log(expr, #expr)) \
|
|
return (r); \
|
|
} while (false)
|
|
|
|
#define assert_return_errno(expr, r, err) \
|
|
do { \
|
|
if (!assert_log(expr, #expr)) { \
|
|
errno = err; \
|
|
return (r); \
|
|
} \
|
|
} while (false)
|