chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sd-daemon: introduce sd_pid_notify() and sd_pid_notifyf()
[elogind.git]
/
src
/
shared
/
util.c
diff --git
a/src/shared/util.c
b/src/shared/util.c
index 0c273943e7e671d20439dd7f7962e5c382d50032..7a4dacd2138ca52eff63e338ddf255d893e516ef 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-1371,23
+1371,27
@@
bool ignore_file(const char *filename) {
assert(filename);
if (endswith(filename, "~"))
assert(filename);
if (endswith(filename, "~"))
- return
fals
e;
+ return
tru
e;
return ignore_file_allow_backup(filename);
}
int fd_nonblock(int fd, bool nonblock) {
return ignore_file_allow_backup(filename);
}
int fd_nonblock(int fd, bool nonblock) {
- int flags;
+ int flags
, nflags
;
assert(fd >= 0);
assert(fd >= 0);
- if ((flags = fcntl(fd, F_GETFL, 0)) < 0)
+ flags = fcntl(fd, F_GETFL, 0);
+ if (flags < 0)
return -errno;
if (nonblock)
return -errno;
if (nonblock)
-
flags |=
O_NONBLOCK;
+
nflags = flags |
O_NONBLOCK;
else
else
- flags &= ~O_NONBLOCK;
+ nflags = flags & ~O_NONBLOCK;
+
+ if (nflags == flags)
+ return 0;
if (fcntl(fd, F_SETFL, flags) < 0)
return -errno;
if (fcntl(fd, F_SETFL, flags) < 0)
return -errno;
@@
-1396,17
+1400,21
@@
int fd_nonblock(int fd, bool nonblock) {
}
int fd_cloexec(int fd, bool cloexec) {
}
int fd_cloexec(int fd, bool cloexec) {
- int flags;
+ int flags
, nflags
;
assert(fd >= 0);
assert(fd >= 0);
- if ((flags = fcntl(fd, F_GETFD, 0)) < 0)
+ flags = fcntl(fd, F_GETFD, 0);
+ if (flags < 0)
return -errno;
if (cloexec)
return -errno;
if (cloexec)
-
flags |=
FD_CLOEXEC;
+
nflags = flags |
FD_CLOEXEC;
else
else
- flags &= ~FD_CLOEXEC;
+ nflags = flags & ~FD_CLOEXEC;
+
+ if (nflags == flags)
+ return 0;
if (fcntl(fd, F_SETFD, flags) < 0)
return -errno;
if (fcntl(fd, F_SETFD, flags) < 0)
return -errno;
@@
-6480,8
+6488,7
@@
void hexdump(FILE *f, const void *p, size_t s) {
}
}
}
}
-int update_reboot_param_file(const char *param)
-{
+int update_reboot_param_file(const char *param) {
int r = 0;
if (param) {
int r = 0;
if (param) {