Add yet another tiny helper to manipulate flags

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-04-10 16:40:48 +02:00
parent 7d6342e401
commit 0da965037e
4 changed files with 7 additions and 20 deletions
+2 -10
View File
@@ -144,11 +144,7 @@ int fd_nonblock(int fd, bool nonblock) {
if (flags < 0)
return -errno;
if (nonblock)
nflags = flags | O_NONBLOCK;
else
nflags = flags & ~O_NONBLOCK;
nflags = UPDATE_FLAG(flags, O_NONBLOCK, nonblock);
if (nflags == flags)
return 0;
@@ -167,11 +163,7 @@ int fd_cloexec(int fd, bool cloexec) {
if (flags < 0)
return -errno;
if (cloexec)
nflags = flags | FD_CLOEXEC;
else
nflags = flags & ~FD_CLOEXEC;
nflags = UPDATE_FLAG(flags, FD_CLOEXEC, cloexec);
if (nflags == flags)
return 0;