diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-04-20 10:10:35 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-04-24 20:51:51 +0200 |
commit | 6f81bcef2558835dc2265f932d4b22a8b9424db2 (patch) | |
tree | 03acbb7bac6c20282b73cf5790605d1797374459 /src/basic/fd-util.h | |
parent | 13d9669980cf3ec19e036d1d99e6b5b60f0695a7 (diff) | |
download | systemd-6f81bcef2558835dc2265f932d4b22a8b9424db2.tar.gz |
fd-util: add ASSERT_FD() that is similar to ASSERT_PTR() but for fds
Diffstat (limited to 'src/basic/fd-util.h')
-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_; \ + }) |