diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-04-25 09:54:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 09:54:20 +0200 |
commit | 3cd60148b44e9947de9557c93c2dd93a2f6978a9 (patch) | |
tree | da38b1615fd57470c6f92278a68e2b562105255d /src/basic | |
parent | afc47ee2af456d12670df862457dcc7f6b864d79 (diff) | |
parent | 8e398254ba6e5027d2774042e0283ac495e64726 (diff) | |
download | systemd-3cd60148b44e9947de9557c93c2dd93a2f6978a9.tar.gz |
Merge pull request #27388 from poettering/assert-fd
add ASSERT_FD() similar to ASSERT_PTR(), but for fds
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/fd-util.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 655ad29284..2f59e334c5 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -121,3 +121,11 @@ static inline char *format_proc_fd_path(char buf[static PROC_FD_PATH_MAX], int f format_proc_fd_path((char[PROC_FD_PATH_MAX]) {}, (fd)) const char *accmode_to_string(int flags); + +/* Like ASSERT_PTR, but for fds */ +#define ASSERT_FD(fd) \ + ({ \ + int _fd_ = (fd); \ + assert(_fd_ >= 0); \ + _fd_; \ + }) |