summaryrefslogtreecommitdiffstats
path: root/ctdb/common/ctdb_util.c
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2013-11-11 12:40:28 +1100
committerMichael Adam <obnox@samba.org>2013-11-19 17:13:05 +0100
commit7562701153c97c22ceeeb3bfe995b8a74965a543 (patch)
treebdbe7f28253507ab18568e58d70c2645348996ee /ctdb/common/ctdb_util.c
parentc72e745511d7187388a0f12566086140d8164845 (diff)
downloadsamba-7562701153c97c22ceeeb3bfe995b8a74965a543.tar.gz
samba-7562701153c97c22ceeeb3bfe995b8a74965a543.tar.xz
samba-7562701153c97c22ceeeb3bfe995b8a74965a543.zip
ctdb-common: Coverity fixes
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'ctdb/common/ctdb_util.c')
-rw-r--r--ctdb/common/ctdb_util.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index 7a70fea9cd7..44eb0db48b0 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -415,16 +415,34 @@ void ctdb_restore_scheduler(struct ctdb_context *ctdb)
void set_nonblocking(int fd)
{
- unsigned v;
+ int v;
+
v = fcntl(fd, F_GETFL, 0);
- fcntl(fd, F_SETFL, v | O_NONBLOCK);
+ if (v == -1) {
+ DEBUG(DEBUG_WARNING, ("Failed to get file status flags - %s\n",
+ strerror(errno)));
+ return;
+ }
+ if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) {
+ DEBUG(DEBUG_WARNING, ("Failed to set non_blocking on fd - %s\n",
+ strerror(errno)));
+ }
}
void set_close_on_exec(int fd)
{
- unsigned v;
+ int v;
+
v = fcntl(fd, F_GETFD, 0);
- fcntl(fd, F_SETFD, v | FD_CLOEXEC);
+ if (v == -1) {
+ DEBUG(DEBUG_WARNING, ("Failed to get file descriptor flags - %s\n",
+ strerror(errno)));
+ return;
+ }
+ if (fcntl(fd, F_SETFD, v | FD_CLOEXEC) != 0) {
+ DEBUG(DEBUG_WARNING, ("Failed to set close_on_exec on fd - %s\n",
+ strerror(errno)));
+ }
}
@@ -821,7 +839,7 @@ void ctdb_mkdir_p_or_die(struct ctdb_context *ctdb, const char *dir, int mode)
DEBUG(DEBUG_ALERT,
("ctdb exiting with error: "
"failed to create directory \"%s\" (%s)\n",
- dir, strerror(ret)));
+ dir, strerror(errno)));
exit(1);
}
}