summaryrefslogtreecommitdiff
path: root/src/basic/fd-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-02-14 17:22:18 +0100
committerLennart Poettering <lennart@poettering.net>2022-02-14 17:27:18 +0100
commit675e7fc22c7ab45bf9f4a4414bf7c87734a00d15 (patch)
treeb34f57a143a0a697572cf2ffbdb71fbc17e2d088 /src/basic/fd-util.c
parenta9dac7a6dd31225dbe9633061dcade12c0c90a32 (diff)
downloadsystemd-675e7fc22c7ab45bf9f4a4414bf7c87734a00d15.tar.gz
fd-util: use ERRNO_IS_XYZ() macros where appropriate
Diffstat (limited to 'src/basic/fd-util.c')
-rw-r--r--src/basic/fd-util.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index a0836aabd1..c02b52992b 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -417,14 +417,11 @@ int same_fd(int a, int b) {
assert(a >= 0);
assert(b >= 0);
- /* Compares two file descriptors. Note that semantics are
- * quite different depending on whether we have kcmp() or we
- * don't. If we have kcmp() this will only return true for
- * dup()ed file descriptors, but not otherwise. If we don't
- * have kcmp() this will also return true for two fds of the same
- * file, created by separate open() calls. Since we use this
- * call mostly for filtering out duplicates in the fd store
- * this difference hopefully doesn't matter too much. */
+ /* Compares two file descriptors. Note that semantics are quite different depending on whether we
+ * have kcmp() or we don't. If we have kcmp() this will only return true for dup()ed file
+ * descriptors, but not otherwise. If we don't have kcmp() this will also return true for two fds of
+ * the same file, created by separate open() calls. Since we use this call mostly for filtering out
+ * duplicates in the fd store this difference hopefully doesn't matter too much. */
if (a == b)
return true;
@@ -436,7 +433,7 @@ int same_fd(int a, int b) {
return true;
if (r > 0)
return false;
- if (!IN_SET(errno, ENOSYS, EACCES, EPERM))
+ if (!ERRNO_IS_NOT_SUPPORTED(errno) && !ERRNO_IS_PRIVILEGE(errno))
return -errno;
/* We don't have kcmp(), use fstat() instead. */
@@ -449,9 +446,8 @@ int same_fd(int a, int b) {
if (!stat_inode_same(&sta, &stb))
return false;
- /* We consider all device fds different, since two device fds
- * might refer to quite different device contexts even though
- * they share the same inode and backing dev_t. */
+ /* We consider all device fds different, since two device fds might refer to quite different device
+ * contexts even though they share the same inode and backing dev_t. */
if (S_ISCHR(sta.st_mode) || S_ISBLK(sta.st_mode))
return false;