diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 04761e4..7349beb 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -25,7 +25,7 @@ else
 	CLEAN = $(shell if [ ! "x$(PREVBUILD)" = "x" ]; then echo clean; fi)
 endif
 
-LIBDM_API_FLUSH = $(shell objdump -T /lib/libdevmapper.so.* | grep -c dm_task_no_flush)
+LIBDM_API_FLUSH = $(shell if test -d /lib64 ; then objdump -T /lib64/libdevmapper.so.* ; else objdump -T /lib/libdevmapper.so.* ; fi | grep -c dm_task_no_flush)
 
 ifeq ($(strip $(LIBDM_API_FLUSH)),1)
 	CFLAGS += -DLIBDM_API_FLUSH
diff --git a/libmultipath/alias.c b/libmultipath/alias.c
index 80cdfa5..aff32f7 100644
--- a/libmultipath/alias.c
+++ b/libmultipath/alias.c
@@ -149,7 +149,7 @@ open_bindings_file(char *file, int *can_write)
 	}
 	if (*can_write && lock_bindings_file(fd) < 0)
 		goto fail;
-	
+
 	memset(&s, 0, sizeof(s));
 	if (fstat(fd, &s) < 0){
 		condlog(0, "Cannot stat bindings file : %s", strerror(errno));
@@ -161,17 +161,19 @@ open_bindings_file(char *file, int *can_write)
 		/* If bindings file is empty, write the header */
 		size_t len = strlen(BINDINGS_FILE_HEADER);
 		if (write_all(fd, BINDINGS_FILE_HEADER, len) != len) {
+			int r;
+
 			condlog(0,
 				"Cannot write header to bindings file : %s",
 				strerror(errno));
-			/* cleanup partially written header */
-			ftruncate(fd, 0);
+			/* cleanup partially written header, ignore  */
+			r = ftruncate(fd, 0);
 			goto fail;
 		}
 		fsync(fd);
 		condlog(3, "Initialized new bindings file [%s]", file);
 	}
-	
+
 	return fd;
 
 fail:
@@ -333,10 +335,12 @@ allocate_binding(int fd, char *wwid, int id)
 		return NULL;
 	}
 	if (write_all(fd, buf, strlen(buf)) != strlen(buf)){
+		int r;
+
 		condlog(0, "Cannot write binding to bindings file : %s",
 			strerror(errno));
-		/* clear partial write */
-		ftruncate(fd, offset);
+		/* clear partial write; error can be ignored */
+		r = ftruncate(fd, offset);
 		return NULL;
 	}
 	c = strchr(buf, ' ');
diff --git a/libmultipath/callout.c b/libmultipath/callout.c
index b0bc503..d4bed07 100644
--- a/libmultipath/callout.c
+++ b/libmultipath/callout.c
@@ -76,7 +76,8 @@ int execute_program(char *path, char *value, int len)
 		close(STDOUT_FILENO);
 
 		/* dup write side of pipe to STDOUT */
-		dup(fds[1]);
+		if (dup(fds[1]) < 0)
+			return -1;
 
 		retval = execvp(argv[0], argv);
 
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 55d40dd..e6ef2c6 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -249,7 +249,7 @@ devt2devname (char *devname, char *devt)
 	while (!feof(fd)) {
 		int r = fscanf(fd,"%u %u %*d %s",&tmpmaj, &tmpmin, dev);
 		if (!r) {
-			fscanf(fd,"%*s\n");
+			r = fscanf(fd,"%*s\n");
 			continue;
 		}
 		if (r != 3)
diff --git a/multipathd/main.c b/multipathd/main.c
index 6441760..f6ed7a9 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -1426,15 +1426,28 @@ daemonize(void)
 	}
 
 	close(STDIN_FILENO);
-	dup(in_fd);
+	if (dup(in_fd) < 0) {
+		fprintf(stderr, "cannot duplicate /dev/null for input"
+			": %s\n", strerror(errno));
+		_exit(0);
+	}
 	close(STDOUT_FILENO);
-	dup(out_fd);
+	if (dup(out_fd) < 0) {
+		fprintf(stderr, "cannot duplicate /dev/console for output"
+			": %s\n", strerror(errno));
+		_exit(0);
+	}
 	close(STDERR_FILENO);
-	dup(out_fd);
-
+	if (dup(out_fd) < 0) {
+		fprintf(stderr, "cannot duplicate /dev/console for error"
+			": %s\n", strerror(errno));
+		_exit(0);
+	}
 	close(in_fd);
 	close(out_fd);
-	chdir("/");
+	if (chdir("/") < 0)
+		fprintf(stderr, "cannot chdir to '/', continuing\n");
+
 	umask(0);
 	return 0;
 }
@@ -1456,7 +1469,9 @@ main (int argc, char *argv[])
 	}
 
 	/* make sure we don't lock any path */
-	chdir("/");
+	if (chdir("/") < 0)
+		fprintf(stderr, "couldn't chdir to '/', continuing\n");
+
 	umask(umask(077) | 022);
 
 	conf = alloc_config();
