macro: Introduce ABS() macro and use it in header files

abs() requires including the entirety of stdlib.h just for a single
trivial function. Let's introduce the ABS() macro and use it in header
files instead so we can get rid of stdlib.h transitive includes in header
files in a later commit.
This commit is contained in:
Daan De Meyer
2025-05-06 10:14:26 +02:00
parent c94f6ab1bf
commit 40a6cdc29e
9 changed files with 23 additions and 15 deletions
@@ -6,6 +6,8 @@
#include <stdbool.h>
#include <stddef.h>
#include "macro.h"
/* crypt_dump() internal indentation magic */
#define CRYPT_DUMP_LINE_SEP "\n\t "
@@ -15,7 +17,7 @@
#define crypt_log(cd, ...) crypt_logf(cd, CRYPT_LOG_NORMAL, __VA_ARGS__)
#define crypt_log_full_errno(cd, e, lvl, ...) ({ \
int _e = abs(e), _s = errno; \
int _e = ABS(e), _s = errno; \
errno = _e; \
crypt_logf(cd, lvl, __VA_ARGS__); \
errno = _s; \