Merge pull request #27388 from poettering/assert-fd

add ASSERT_FD() similar to ASSERT_PTR(), but for fds
This commit is contained in:
Lennart Poettering
2023-04-25 09:54:20 +02:00
committed by GitHub
2 changed files with 17 additions and 20 deletions
+8
View File
@@ -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_; \
})