projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
13d9669
)
fd-util: add ASSERT_FD() that is similar to ASSERT_PTR() but for fds
author
Lennart Poettering
<lennart@poettering.net>
Thu, 20 Apr 2023 08:10:35 +0000
(10:10 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Mon, 24 Apr 2023 18:51:51 +0000
(20:51 +0200)
src/basic/fd-util.h
patch
|
blob
|
history
diff --git
a/src/basic/fd-util.h
b/src/basic/fd-util.h
index 655ad2928475173d04b138a3ecf42dff1ccc8571..2f59e334c5c12051405b3bfa94ef3ac2fbe80aa7 100644
(file)
--- 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_; \
+ })