[patchset] introduce an -O3 autobuild target - and fix a lot of errors

Michael Adam obnox at samba.org
Mon Apr 11 08:35:08 UTC 2016


Hi,

Attached find a patchset that implements an autobuild target
'samba-o3', that builds with -O3 and runs some tests against
the result (make quicktest...).

In order to enable this target by default, I had to fix quite
a lot of -O3 errors, so that the build would pass on our
autobuild server. Now it passes on ubuntu 14.04 and fedora 23
at least.

Andrew: I have kept at a separate build target because I
also wanted to make sure to run at least a subset of the
testsuite against it. Hence I did not add it to the static
target.

Review / comments welcome!

Cheers - Michael
-------------- next part --------------
From 9959e59d4cf16dc4a9326f70187c403086b2e15f Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 22 Mar 2016 18:14:17 +0100
Subject: [PATCH 01/41] autobuild: add a target samba-o3 that is built with -O3

Only run quicktest against the ad_dc env.
This currently just takes some 6 odd minutes.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 script/autobuild.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/script/autobuild.py b/script/autobuild.py
index 4cad920..6b7eca2 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -24,6 +24,7 @@ builddirs = {
     "ctdb"    : "ctdb",
     "samba"  : ".",
     "samba-xc" : ".",
+    "samba-o3" : ".",
     "samba-ctdb" : ".",
     "samba-libs"  : ".",
     "samba-static"  : ".",
@@ -79,6 +80,14 @@ tasks = {
                     " --cross-answers=./bin-xe/cross-answers.txt --with-selftest-prefix=./bin-xa/ab" + samba_configure_params, "text/plain"),
                    ("compare-results", "script/compare_cc_results.py ./bin/c4che/default.cache.py ./bin-xe/c4che/default.cache.py ./bin-xa/c4che/default.cache.py", "text/plain")],
 
+    # test build with -O3 -- catches extra warnings and bugs
+    "samba-o3" : [ ("random-sleep", "../script/random-sleep.sh 60 600", "text/plain"),
+                   ("configure", "ADDITIONAL_CFLAGS='-O3' ./configure.developer --with-selftest-prefix=./bin/ab" + samba_configure_params, "text/plain"),
+                   ("make", "make -j", "text/plain"),
+                   ("test", "make quicktest FAIL_IMMEDIATELY=1 TESTS='\(ad_dc\)'", "text/plain"),
+                   ("install", "make install", "text/plain"),
+                   ("check-clean-tree", "script/clean-source-tree.sh", "text/plain"),
+                   ("clean", "make clean", "text/plain") ],
 
     "samba-ctdb" : [ ("random-sleep", "script/random-sleep.sh 60 600", "text/plain"),
 
-- 
2.5.5


From 683f0b710f0ea57ebc469eea1005029101553475 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 23 Mar 2016 01:41:17 +0100
Subject: [PATCH 02/41] tevent:threads: fix -O3 error unused result of write

some compilers don't tolerate void-casting for warn_unused_result

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/tevent_threads.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/tevent/tevent_threads.c b/lib/tevent/tevent_threads.c
index 8d44e4f..b7332c0 100644
--- a/lib/tevent/tevent_threads.c
+++ b/lib/tevent/tevent_threads.c
@@ -310,6 +310,7 @@ void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp,
 	struct tevent_immediate_list *im_entry;
 	int ret;
 	char c;
+	ssize_t written;
 
 	ret = pthread_mutex_lock(&tp->mutex);
 	if (ret != 0) {
@@ -341,7 +342,9 @@ void tevent_thread_proxy_schedule(struct tevent_thread_proxy *tp,
 
 	/* And notify the dest_ev_ctx to wake up. */
 	c = '\0';
-	(void)write(tp->write_fd, &c, 1);
+	do {
+		written = write(tp->write_fd, &c, 1);
+	} while (written == -1 && (errno == EINTR || errno == EAGAIN));
 
   end:
 
-- 
2.5.5


From 42a4fddd9c666d9dbf6c51272bb5c94b85fbbd0c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 23 Mar 2016 01:41:29 +0100
Subject: [PATCH 03/41] tevent:signal: fix -O3 error unused result of write

some compilers don't tolerate void-casting for warn_unused_result

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/tevent_signal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index 9bc11ed..9ec6bbd 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -106,9 +106,13 @@ static void tevent_common_signal_handler(int signum)
 	/* Write to each unique event context. */
 	for (sl = sig_state->sig_handlers[signum]; sl; sl = sl->next) {
 		if (sl->se->event_ctx && sl->se->event_ctx != ev) {
+			ssize_t ret;
+
 			ev = sl->se->event_ctx;
 			/* doesn't matter if this pipe overflows */
-			(void) write(ev->pipe_fds[1], &c, 1);
+			do {
+				ret = write(ev->pipe_fds[1], &c, 1);
+			} while (ret == -1 && (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK));
 		}
 	}
 
-- 
2.5.5


From 040b04e700fabff1e8a2247ca5213e0a05801203 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 23 Mar 2016 02:23:35 +0100
Subject: [PATCH 04/41] tevent:signal: fix -O3 error unused result of read

some compilers don't tolerate void-casting for warn_unused_result

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/tevent_signal.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/tevent/tevent_signal.c b/lib/tevent/tevent_signal.c
index 9ec6bbd..9eebd2f 100644
--- a/lib/tevent/tevent_signal.c
+++ b/lib/tevent/tevent_signal.c
@@ -238,9 +238,13 @@ static int tevent_signal_destructor(struct tevent_signal *se)
 static void signal_pipe_handler(struct tevent_context *ev, struct tevent_fd *fde, 
 				uint16_t flags, void *_private)
 {
+	ssize_t ret;
+
 	char c[16];
 	/* its non-blocking, doesn't matter if we read too much */
-	(void) read(fde->fd, c, sizeof(c));
+	do {
+		ret = read(fde->fd, c, sizeof(c));
+	} while (ret == -1 && (errno = EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
 }
 
 /*
-- 
2.5.5


From b55b1631f5d445f021da4a3d881317916b0ae387 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:40:37 +0200
Subject: [PATCH 05/41] tevent:testsuite: fix O3 errors unused result for read

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/testsuite.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/tevent/testsuite.c b/lib/tevent/testsuite.c
index bcd27fd..4d16be7 100644
--- a/lib/tevent/testsuite.c
+++ b/lib/tevent/testsuite.c
@@ -43,12 +43,15 @@ static void fde_handler_read(struct tevent_context *ev_ctx, struct tevent_fd *f,
 {
 	int *fd = (int *)private_data;
 	char c;
+	ssize_t nread;
 #ifdef SA_SIGINFO
 	kill(getpid(), SIGUSR1);
 #endif
 	kill(getpid(), SIGALRM);
 
-	read(fd[0], &c, 1);
+	do {
+		nread = read(fd[0], &c, 1);
+	} while ((nread == -1) && (errno == EINTR));
 	fde_count++;
 }
 
@@ -67,12 +70,15 @@ static void fde_handler_read_1(struct tevent_context *ev_ctx, struct tevent_fd *
 {
 	int *fd = (int *)private_data;
 	char c;
+	ssize_t nread;
 #ifdef SA_SIGINFO
 	kill(getpid(), SIGUSR1);
 #endif
 	kill(getpid(), SIGALRM);
 
-	read(fd[1], &c, 1);
+	do {
+		nread = read(fd[1], &c, 1);
+	} while ((nread == -1) && (errno == EINTR));
 	fde_count++;
 }
 
-- 
2.5.5


From 12def21a280b7a6ad93d4793d8c98b28cc8cda98 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:51:13 +0200
Subject: [PATCH 06/41] tevent:testsuite: fix O3 errors unused result of write

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tevent/testsuite.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/tevent/testsuite.c b/lib/tevent/testsuite.c
index 4d16be7..e8f2f68 100644
--- a/lib/tevent/testsuite.c
+++ b/lib/tevent/testsuite.c
@@ -55,12 +55,22 @@ static void fde_handler_read(struct tevent_context *ev_ctx, struct tevent_fd *f,
 	fde_count++;
 }
 
+static void do_write(int fd, void *buf, size_t count)
+{
+	ssize_t ret;
+
+	do {
+		ret = write(fd, buf, count);
+	} while ((ret == -1) && (errno == EINTR));
+}
+
 static void fde_handler_write(struct tevent_context *ev_ctx, struct tevent_fd *f,
 			uint16_t flags, void *private_data)
 {
 	int *fd = (int *)private_data;
 	char c = 0;
-	write(fd[1], &c, 1);
+
+	do_write(fd[1], &c, 1);
 }
 
 
@@ -88,7 +98,7 @@ static void fde_handler_write_1(struct tevent_context *ev_ctx, struct tevent_fd
 {
 	int *fd = (int *)private_data;
 	char c = 0;
-	write(fd[0], &c, 1);
+	do_write(fd[0], &c, 1);
 }
 
 static void finished_handler(struct tevent_context *ev_ctx, struct tevent_timer *te,
@@ -287,7 +297,7 @@ static void test_event_fd1_fde_handler(struct tevent_context *ev_ctx,
 		/*
 		 * we write to the other socket...
 		 */
-		write(state->sock[1], &c, 1);
+		do_write(state->sock[1], &c, 1);
 		TEVENT_FD_NOT_WRITEABLE(fde);
 		TEVENT_FD_READABLE(fde);
 		return;
@@ -656,9 +666,9 @@ static bool test_event_fd2(struct torture_context *tctx,
 	tevent_fd_set_auto_close(state.sock0.fde);
 	tevent_fd_set_auto_close(state.sock1.fde);
 
-	write(state.sock0.fd, &c, 1);
+	do_write(state.sock0.fd, &c, 1);
 	state.sock0.num_written++;
-	write(state.sock1.fd, &c, 1);
+	do_write(state.sock1.fd, &c, 1);
 	state.sock1.num_written++;
 
 	while (!state.finished) {
@@ -798,7 +808,7 @@ static bool test_event_context_threaded(struct torture_context *test,
 
 	poll(NULL, 0, 100);
 
-	write(fds[1], &c, 1);
+	do_write(fds[1], &c, 1);
 
 	poll(NULL, 0, 100);
 
@@ -806,7 +816,7 @@ static bool test_event_context_threaded(struct torture_context *test,
 	do_shutdown = true;
 	test_event_threaded_unlock();
 
-	write(fds[1], &c, 1);
+	do_write(fds[1], &c, 1);
 
 	ret = pthread_join(poll_thread, NULL);
 	torture_assert(test, ret == 0, "pthread_join failed");
-- 
2.5.5


From 4470fefed46710d1de5fe6ea8a7deb38c7133fa9 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 23 Mar 2016 02:36:04 +0100
Subject: [PATCH 07/41] tdb:torture: fix -O3 error unused result code of read

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tdb/tools/tdbtorture.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c
index e4b8f69..ae5a235 100644
--- a/lib/tdb/tools/tdbtorture.c
+++ b/lib/tdb/tools/tdbtorture.c
@@ -427,8 +427,15 @@ int main(int argc, char * const *argv)
 			    || WTERMSIG(status) == SIGUSR1) {
 				/* SIGUSR2 means they wrote to pipe. */
 				if (WTERMSIG(status) == SIGUSR2) {
-					read(pfds[0], &done[j],
-					     sizeof(done[j]));
+					ssize_t ret;
+
+					do {
+						ret = read(pfds[0], &done[j],
+							   sizeof(done[j]));
+					} while (ret == -1 &&
+						 (errno == EINTR ||
+						  errno == EAGAIN ||
+						  errno == EWOULDBLOCK));
 				}
 				pids[j] = fork();
 				if (pids[j] == 0)
-- 
2.5.5


From 5f3c0c6074e714af15ffa8c471ea9d52e2aa1cea Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 23 Mar 2016 02:47:13 +0100
Subject: [PATCH 08/41] tdb:torture: fix -O3 error unused result of write

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/tdb/tools/tdbtorture.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/tdb/tools/tdbtorture.c b/lib/tdb/tools/tdbtorture.c
index ae5a235..acfc3cd 100644
--- a/lib/tdb/tools/tdbtorture.c
+++ b/lib/tdb/tools/tdbtorture.c
@@ -223,8 +223,12 @@ static void usage(void)
 
 static void send_count_and_suicide(int sig)
 {
+	ssize_t ret;
+
 	/* This ensures our successor can continue where we left off. */
-	write(count_pipe, &loopnum, sizeof(loopnum));
+	do {
+		ret = write(count_pipe, &loopnum, sizeof(loopnum));
+	} while (ret == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
 	/* This gives a unique signature. */
 	kill(getpid(), SIGUSR2);
 }
-- 
2.5.5


From 841f8634caf0c6646c768d973051913f71d0ad6a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 22 Mar 2016 23:01:10 +0100
Subject: [PATCH 09/41] debug: fix -O3 warning - unused return code of write()

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/util/debug.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/util/debug.c b/lib/util/debug.c
index 4bb54d7..ab979c8 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -139,8 +139,12 @@ static int debug_level_to_priority(int level)
 static void debug_file_log(int msg_level,
 			   const char *msg, const char *msg_no_nl)
 {
+	ssize_t ret;
+
 	check_log_size();
-	write(state.fd, msg, strlen(msg));
+	do {
+		ret = write(state.fd, msg, strlen(msg));
+	} while (ret == -1 && (errno = EINTR || errno == EAGAIN));
 }
 
 #ifdef WITH_SYSLOG
@@ -1114,7 +1118,10 @@ static void Debug1(const char *msg)
 	case DEBUG_DEFAULT_STDOUT:
 	case DEBUG_DEFAULT_STDERR:
 		if (state.fd > 0) {
-			write(state.fd, msg, strlen(msg));
+			ssize_t ret;
+			do {
+				ret = write(state.fd, msg, strlen(msg));
+			} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
 		}
 		break;
 	case DEBUG_FILE:
-- 
2.5.5


From 8d4b99b5e651923574dd351708345986b56a8885 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Mar 2016 01:28:27 +0100
Subject: [PATCH 10/41] lib: add sys_read_v - void variant of sys_read

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/util/sys_rw.c | 14 ++++++++++++++
 lib/util/sys_rw.h |  1 +
 2 files changed, 15 insertions(+)

diff --git a/lib/util/sys_rw.c b/lib/util/sys_rw.c
index f625066..19b086e 100644
--- a/lib/util/sys_rw.c
+++ b/lib/util/sys_rw.c
@@ -40,6 +40,20 @@ ssize_t sys_read(int fd, void *buf, size_t count)
 	return ret;
 }
 
+/**
+ * read wrapper. void variant
+ */
+void sys_read_v(int fd, void *buf, size_t count)
+{
+	ssize_t ret;
+
+	do {
+		ret = read(fd, buf, count);
+	} while (ret == -1 && (errno == EINTR || errno == EAGAIN ||
+			       errno == EWOULDBLOCK));
+}
+
+
 /*******************************************************************
 A write wrapper that will deal with EINTR/EWOULDBLOCK.
 ********************************************************************/
diff --git a/lib/util/sys_rw.h b/lib/util/sys_rw.h
index ee1584e..6b708a8 100644
--- a/lib/util/sys_rw.h
+++ b/lib/util/sys_rw.h
@@ -28,6 +28,7 @@
 struct iovec;
 
 ssize_t sys_read(int fd, void *buf, size_t count);
+void sys_read_v(int fd, void *buf, size_t count);
 ssize_t sys_write(int fd, const void *buf, size_t count);
 ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
 ssize_t sys_pread(int fd, void *buf, size_t count, off_t off);
-- 
2.5.5


From 72504e3a925a396cf82d63400f110ab7c8f10f0c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Mar 2016 01:28:56 +0100
Subject: [PATCH 11/41] lib: add sys_write_v - void variant of sys_write

Signed-off-by: Michael Adam <obnox at samba.org>
---
 lib/util/sys_rw.c | 15 +++++++++++++++
 lib/util/sys_rw.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/lib/util/sys_rw.c b/lib/util/sys_rw.c
index 19b086e..5486cb5 100644
--- a/lib/util/sys_rw.c
+++ b/lib/util/sys_rw.c
@@ -70,6 +70,21 @@ ssize_t sys_write(int fd, const void *buf, size_t count)
 	return ret;
 }
 
+/**
+ * write wrapper to deal with EINTR and friends.
+ * void-variant that ignores the number of bytes written.
+ */
+void sys_write_v(int fd, const void *buf, size_t count)
+{
+	ssize_t ret;
+
+	do {
+		ret = write(fd, buf, count);
+	} while (ret == -1 && (errno == EINTR || errno == EAGAIN ||
+			       errno == EWOULDBLOCK));
+}
+
+
 /*******************************************************************
 A writev wrapper that will deal with EINTR.
 ********************************************************************/
diff --git a/lib/util/sys_rw.h b/lib/util/sys_rw.h
index 6b708a8..ab456d8 100644
--- a/lib/util/sys_rw.h
+++ b/lib/util/sys_rw.h
@@ -30,6 +30,7 @@ struct iovec;
 ssize_t sys_read(int fd, void *buf, size_t count);
 void sys_read_v(int fd, void *buf, size_t count);
 ssize_t sys_write(int fd, const void *buf, size_t count);
+void sys_write_v(int fd, const void *buf, size_t count);
 ssize_t sys_writev(int fd, const struct iovec *iov, int iovcnt);
 ssize_t sys_pread(int fd, void *buf, size_t count, off_t off);
 ssize_t sys_pwrite(int fd, const void *buf, size_t count, off_t off);
-- 
2.5.5


From ce729c63307701016a08c7b90fd91aecfe45810e Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Mar 2016 01:29:40 +0100
Subject: [PATCH 12/41] s4:libcli:resolve: fix O3-warning: use return code of
 write

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/libcli/resolve/dns_ex.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c
index 08b6932..6174b61 100644
--- a/source4/libcli/resolve/dns_ex.c
+++ b/source4/libcli/resolve/dns_ex.c
@@ -41,6 +41,7 @@
 #include "lib/util/util_net.h"
 #include "lib/addns/dnsquery.h"
 #include "lib/addns/dns.h"
+#include "lib/util/sys_rw.h"
 #include <arpa/nameser.h>
 #include <resolv.h>
 
@@ -370,7 +371,7 @@ static void run_child_dns_lookup(struct dns_ex_state *state, int fd)
 
 	if (addrs) {
 		DEBUG(11, ("Addrs = %s\n", addrs));
-		write(fd, addrs, talloc_get_size(addrs));
+		sys_write_v(fd, addrs, talloc_get_size(addrs));
 	}
 
 done:
@@ -436,7 +437,7 @@ static void run_child_getaddrinfo(struct dns_ex_state *state, int fd)
 	}
 
 	if (addrs) {
-		write(fd, addrs, talloc_get_size(addrs));
+		sys_write_v(fd, addrs, talloc_get_size(addrs));
 	}
 done:
 	if (res_list) {
-- 
2.5.5


From 907e36949c13651f5beed336604aeea9604d67b0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 25 Mar 2016 02:04:58 +0100
Subject: [PATCH 13/41] s3:registry:patchfile: fix O3 warning: use return code
 of write

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/lib/registry/patchfile_preg.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/source4/lib/registry/patchfile_preg.c b/source4/lib/registry/patchfile_preg.c
index 8017b58..19ebb6a 100644
--- a/source4/lib/registry/patchfile_preg.c
+++ b/source4/lib/registry/patchfile_preg.c
@@ -23,6 +23,7 @@
 #include "lib/registry/registry.h"
 #include "system/filesys.h"
 #include "librpc/gen_ndr/winreg.h"
+#include "lib/util/sys_rw.h"
 
 struct preg_data {
 	int fd;
@@ -71,12 +72,12 @@ static WERROR reg_preg_diff_set_value(void *_data, const char *key_name,
 	preg_write_utf16(data->fd, value_name);
 	preg_write_utf16(data->fd, ";");
 	SIVAL(&buf, 0, value_type);
-	write(data->fd, &buf, sizeof(uint32_t));
+	sys_write_v(data->fd, &buf, sizeof(uint32_t));
 	preg_write_utf16(data->fd, ";");
 	SIVAL(&buf, 0, value_data.length);
-	write(data->fd, &buf, sizeof(uint32_t));
+	sys_write_v(data->fd, &buf, sizeof(uint32_t));
 	preg_write_utf16(data->fd, ";");
-	write(data->fd, value_data.data, value_data.length);
+	sys_write_v(data->fd, value_data.data, value_data.length);
 	preg_write_utf16(data->fd, "]");
 	
 	return WERR_OK;
@@ -189,7 +190,7 @@ _PUBLIC_ WERROR reg_preg_diff_save(TALLOC_CTX *ctx, const char *filename,
 
 	memcpy(preg_header.hdr, "PReg", sizeof(preg_header.hdr));
 	SIVAL(&preg_header.version, 0, 1);
-	write(data->fd, (uint8_t *)&preg_header, sizeof(preg_header));
+	sys_write_v(data->fd, (uint8_t *)&preg_header, sizeof(preg_header));
 
 	data->ctx = ctx;
 
-- 
2.5.5


From 6b7d8da290c8807d33fccb69a285f699fa0305d7 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 26 Mar 2016 01:53:00 +0100
Subject: [PATCH 14/41] s4:ntvfs: fix O3 error unused result in
 svfs_map_fileinfo

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/ntvfs/simple/vfs_simple.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/source4/ntvfs/simple/vfs_simple.c b/source4/ntvfs/simple/vfs_simple.c
index 38ecdfe..abd76d2 100644
--- a/source4/ntvfs/simple/vfs_simple.c
+++ b/source4/ntvfs/simple/vfs_simple.c
@@ -206,7 +206,7 @@ static NTSTATUS svfs_map_fileinfo(struct ntvfs_module_context *ntvfs,
 {
 	struct svfs_dir *dir = NULL;
 	char *pattern = NULL;
-	int i;
+	int i, ret;
 	const char *s, *short_name;
 
 	s = strrchr(unix_path, '/');
@@ -216,8 +216,11 @@ static NTSTATUS svfs_map_fileinfo(struct ntvfs_module_context *ntvfs,
 		short_name = "";
 	}
 
-	asprintf(&pattern, "%s:*", unix_path);
-	
+	ret = asprintf(&pattern, "%s:*", unix_path);
+	if (ret == -1) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
 	if (pattern) {
 		dir = svfs_list_unix(req, req, pattern);
 	}
-- 
2.5.5


From 6115392f6e87b1d698943496fa639a7a7f11438c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 26 Mar 2016 02:08:41 +0100
Subject: [PATCH 15/41] s4:ntvfs: fix O3 unused return error in svfs_file_utime

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/ntvfs/simple/svfs_util.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/source4/ntvfs/simple/svfs_util.c b/source4/ntvfs/simple/svfs_util.c
index c4e0156..171813b 100644
--- a/source4/ntvfs/simple/svfs_util.c
+++ b/source4/ntvfs/simple/svfs_util.c
@@ -158,7 +158,12 @@ int svfs_file_utime(int fd, struct utimbuf *times)
 	char *fd_path = NULL;
 	int ret;
 
-	asprintf(&fd_path, "/proc/self/%d", fd);
+	ret = asprintf(&fd_path, "/proc/self/%d", fd);
+	if (ret == -1) {
+		errno = ENOMEM;
+		return -1;
+	}
+
 	if (!fd_path) {
 		errno = ENOMEM;
 		return -1;
-- 
2.5.5


From 7a9334b218e30481e4083664f5eed81be5952a77 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 26 Mar 2016 02:24:08 +0100
Subject: [PATCH 16/41] s4:ntvfs: fix O3 unused return error in
 cifspsx_map_fileinfo

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
index d384dbb..9c1e6f6 100644
--- a/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
+++ b/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c
@@ -209,7 +209,7 @@ static NTSTATUS cifspsx_map_fileinfo(struct ntvfs_module_context *ntvfs,
 {
 	struct cifspsx_dir *dir = NULL;
 	char *pattern = NULL;
-	int i;
+	int i, ret;
 	const char *s, *short_name;
 
 	s = strrchr(unix_path, '/');
@@ -219,8 +219,11 @@ static NTSTATUS cifspsx_map_fileinfo(struct ntvfs_module_context *ntvfs,
 		short_name = "";
 	}
 
-	asprintf(&pattern, "%s:*", unix_path);
-	
+	ret = asprintf(&pattern, "%s:*", unix_path);
+	if (ret == -1) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
 	if (pattern) {
 		dir = cifspsx_list_unix(req, req, pattern);
 	}
-- 
2.5.5


From d7eedbd331076e7687ad3aa0103243b2e20b592e Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 26 Mar 2016 02:46:54 +0100
Subject: [PATCH 17/41] s4:ntvfs: fix O3 unused return error in
 cifspsx_list_unix

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/ntvfs/cifs_posix_cli/svfs_util.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/source4/ntvfs/cifs_posix_cli/svfs_util.c b/source4/ntvfs/cifs_posix_cli/svfs_util.c
index f351c58..a9e6ba4 100644
--- a/source4/ntvfs/cifs_posix_cli/svfs_util.c
+++ b/source4/ntvfs/cifs_posix_cli/svfs_util.c
@@ -94,6 +94,7 @@ struct cifspsx_dir *cifspsx_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request
 		unsigned int i = dir->count;
 		char *full_name;
 		char *low_name;
+		int ret;
 
 		if (strchr(dent->d_name, ':') && !strchr(unix_path, ':')) {
 			/* don't show streams in dir listing */
@@ -120,7 +121,11 @@ struct cifspsx_dir *cifspsx_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request
 		dir->files[i].name = low_name;
 		if (!dir->files[i].name) { continue; }
 
-		asprintf(&full_name, "%s/%s", dir->unix_dir, dir->files[i].name);
+		ret = asprintf(&full_name, "%s/%s", dir->unix_dir, dir->files[i].name);
+		if (ret == -1) {
+			continue;
+		}
+
 		if (!full_name) { continue; }
 
 		if (stat(full_name, &dir->files[i].st) == 0) { 
-- 
2.5.5


From 20337e41d10cd137f2a65ba02cbc756ec0d0085c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 12:18:17 +0200
Subject: [PATCH 18/41] s4:ntvfs: fix O3 unused return code error in
 cifspsx_file_utime()

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/ntvfs/cifs_posix_cli/svfs_util.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/source4/ntvfs/cifs_posix_cli/svfs_util.c b/source4/ntvfs/cifs_posix_cli/svfs_util.c
index a9e6ba4..cf881a1 100644
--- a/source4/ntvfs/cifs_posix_cli/svfs_util.c
+++ b/source4/ntvfs/cifs_posix_cli/svfs_util.c
@@ -165,7 +165,11 @@ int cifspsx_file_utime(int fd, struct utimbuf *times)
 	char *fd_path = NULL;
 	int ret;
 
-	asprintf(&fd_path, "/proc/self/%d", fd);
+	ret = asprintf(&fd_path, "/proc/self/%d", fd);
+	if (ret == -1) {
+		return -1;
+	}
+
 	if (!fd_path) {
 		errno = ENOMEM;
 		return -1;
-- 
2.5.5


From 556652d16f76f22f93e9629ec5b8c3a237706e18 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 12:36:57 +0200
Subject: [PATCH 19/41] s4:ntvfs: fix O3 unused return code of write error in
 nbench_log()

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/ntvfs/nbench/vfs_nbench.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/ntvfs/nbench/vfs_nbench.c b/source4/ntvfs/nbench/vfs_nbench.c
index e6f725a..c3e0a42 100644
--- a/source4/ntvfs/nbench/vfs_nbench.c
+++ b/source4/ntvfs/nbench/vfs_nbench.c
@@ -26,6 +26,7 @@
 #include "includes.h"
 #include "ntvfs/ntvfs.h"
 #include "system/filesys.h"
+#include "lib/util/sys_rw.h"
 
 NTSTATUS ntvfs_nbench_init(void);
 
@@ -56,7 +57,7 @@ static void nbench_log(struct ntvfs_request *req,
 		return;
 	}
 
-	write(nprivates->log_fd, s, strlen(s));
+	sys_write_v(nprivates->log_fd, s, strlen(s));
 	free(s);
 }
 
-- 
2.5.5


From d4652ac1ba23cc59427bcae813ad36c7503eb81a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 15:43:52 +0200
Subject: [PATCH 20/41] s4:regshell: fix O3 error return value of asprintf not
 used in reg_complete_key()

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/lib/registry/tools/regshell.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/source4/lib/registry/tools/regshell.c b/source4/lib/registry/tools/regshell.c
index 448f957..6b61c92 100644
--- a/source4/lib/registry/tools/regshell.c
+++ b/source4/lib/registry/tools/regshell.c
@@ -482,6 +482,7 @@ static char **reg_complete_key(const char *text, int start, int end)
 	const char *base_n = "";
 	TALLOC_CTX *mem_ctx;
 	WERROR status;
+	int ret;
 
 	matches = malloc_array_p(char *, MAX_COMPLETIONS);
 	if (!matches) return NULL;
@@ -529,12 +530,16 @@ static char **reg_complete_key(const char *text, int start, int end)
 	}
 
 	if (j == 2) { /* Exact match */
-		asprintf(&matches[0], "%s%s", base_n, matches[1]);
+		ret = asprintf(&matches[0], "%s%s", base_n, matches[1]);
 	} else {
-		asprintf(&matches[0], "%s%s", base_n,
+		ret = asprintf(&matches[0], "%s%s", base_n,
 				talloc_strndup(mem_ctx, matches[1], samelen));
 	}
 	talloc_free(mem_ctx);
+	if (ret == -1) {
+		SAFE_FREE(matches);
+		return NULL;
+	}
 
 	matches[j] = NULL;
 	return matches;
-- 
2.5.5


From 796444bb8a7c77662ae3f60a28828745235fbfd6 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 16:47:39 +0200
Subject: [PATCH 21/41] s3:samlogon_cache: fix O3 error ignored return of
 truncate

in netsamlogon_cache_init()

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/libsmb/samlogon_cache.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/source3/libsmb/samlogon_cache.c b/source3/libsmb/samlogon_cache.c
index c408082..7be5479 100644
--- a/source3/libsmb/samlogon_cache.c
+++ b/source3/libsmb/samlogon_cache.c
@@ -77,7 +77,13 @@ clear:
 	first_try = false;
 
 	DEBUG(0,("retry after truncate for '%s'\n", path));
-	truncate(path, 0);
+	ret = truncate(path, 0);
+	if (ret == -1) {
+		DBG_ERR("truncate failed: %s\n", strerror(errno));
+		talloc_free(path);
+		return false;
+	}
+
 	goto again;
 }
 
-- 
2.5.5


From 96f3fc5b0715913d84efe4f1ff2d9bc033932a80 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 17:15:29 +0200
Subject: [PATCH 22/41] s4:torture:basic: fix O3 error result of asprintf not
 used

in run_opentest()

While fixing this, also convert to using talloc_asprintf instead.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/base.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index e8ae4b6..3b89c36 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -823,7 +823,9 @@ static bool run_vuidtest(struct torture_context *tctx,
 	int failures = 0;
 	int i;
 
-	asprintf(&control_char_fname, "\\readonly.afile");
+	control_char_fname = talloc_strdup(tctx, "\\readonly.afile");
+	torture_assert_not_null(tctx, control_char_fname, "asprintf failed\n");
+
 	for (i = 1; i <= 0x1f; i++) {
 		control_char_fname[10] = i;
 		fnum1 = smbcli_nt_create_full(cli1->tree, control_char_fname, 0, SEC_FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL,
@@ -842,7 +844,7 @@ static bool run_vuidtest(struct torture_context *tctx,
 		smbcli_setatr(cli1->tree, control_char_fname, 0, 0);
 		smbcli_unlink(cli1->tree, control_char_fname);
 	}
-	free(control_char_fname);
+	TALLOC_FREE(control_char_fname);
 
 	if (!failures)
 		torture_comment(tctx, "Create file with control char names passed.\n");
-- 
2.5.5


From 6091cd2be57d6f20139c3921b8634889b08847d2 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:14:19 +0200
Subject: [PATCH 23/41] s4:torture:basic:misc: fix O3 errors result of asprintf
 ignored

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/misc.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c
index 4e84e38..0a0b0f7 100644
--- a/source4/torture/basic/misc.c
+++ b/source4/torture/basic/misc.c
@@ -70,13 +70,16 @@ static bool rw_torture(struct torture_context *tctx, struct smbcli_state *c)
 
 	for (i=0;i<torture_numops;i++) {
 		unsigned int n = (unsigned int)random()%10;
+		int ret;
+
 		if (i % 10 == 0) {
 			if (torture_setting_bool(tctx, "progress", true)) {
 				torture_comment(tctx, "%d\r", i);
 				fflush(stdout);
 			}
 		}
-		asprintf(&fname, "\\torture.%u", n);
+		ret = asprintf(&fname, "\\torture.%u", n);
+		torture_assert(tctx, ret != -1, "asprintf failed");
 
 		if (!wait_lock(c, fnum2, n*sizeof(int), sizeof(int))) {
 			return false;
@@ -302,6 +305,7 @@ bool torture_maxfid_test(struct torture_context *tctx, struct smbcli_state *cli)
 	int fnums[0x11000], i;
 	int retries=4, maxfid;
 	bool correct = true;
+	int ret;
 
 	if (retries <= 0) {
 		torture_comment(tctx, "failed to connect\n");
@@ -323,7 +327,8 @@ bool torture_maxfid_test(struct torture_context *tctx, struct smbcli_state *cli)
 
 	for (i=0; i<0x11000; i++) {
 		if (i % 1000 == 0) {
-			asprintf(&fname, "\\maxfid\\fid%d", i/1000);
+			ret = asprintf(&fname, "\\maxfid\\fid%d", i/1000);
+			torture_assert(tctx, ret != -1, "asprintf failed");
 			if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) {
 				torture_comment(tctx, "Failed to mkdir %s, error=%s\n", 
 				       fname, smbcli_errstr(cli->tree));
@@ -331,7 +336,8 @@ bool torture_maxfid_test(struct torture_context *tctx, struct smbcli_state *cli)
 			}
 			free(fname);
 		}
-		asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid());
+		ret = asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid());
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		if ((fnums[i] = smbcli_open(cli->tree, fname, 
 					O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) ==
 		    -1) {
@@ -352,7 +358,8 @@ bool torture_maxfid_test(struct torture_context *tctx, struct smbcli_state *cli)
 
 	torture_comment(tctx, "cleaning up\n");
 	for (i=0;i<maxfid;i++) {
-		asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid());
+		ret = asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid());
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnums[i]))) {
 			torture_comment(tctx, "Close of fnum %d failed - %s\n", fnums[i], smbcli_errstr(cli->tree));
 		}
-- 
2.5.5


From 07bd5be1392342a2c5cf22477939855bbf70ce93 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:16:46 +0200
Subject: [PATCH 24/41] s4:torture:basic: fix O3 error result of write ignored
 in test_utable

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/utable.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c
index 0b45692..da2fe2e 100644
--- a/source4/torture/basic/utable.c
+++ b/source4/torture/basic/utable.c
@@ -24,6 +24,7 @@
 #include "torture/util.h"
 #include "param/param.h"
 #include "torture/basic/proto.h"
+#include "lib/util/sys_rw.h"
 
 bool torture_utable(struct torture_context *tctx, 
 					struct smbcli_state *cli)
@@ -96,7 +97,7 @@ bool torture_utable(struct torture_context *tctx,
 	torture_assert(tctx, fd != -1, 
 		talloc_asprintf(tctx, 
 		"Failed to create valid.dat - %s", strerror(errno)));
-	write(fd, valid, 0x10000);
+	sys_write_v(fd, valid, 0x10000);
 	close(fd);
 	torture_comment(tctx, "wrote valid.dat\n");
 
-- 
2.5.5


From 349ee217f6dd6464f501cc74cdb0cee20da01e76 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:19:30 +0200
Subject: [PATCH 25/41] s4:torture:basic:dir: fix O3 errors result of asprintf
 ignored

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/dir.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/source4/torture/basic/dir.c b/source4/torture/basic/dir.c
index 774730a..2a3d136 100644
--- a/source4/torture/basic/dir.c
+++ b/source4/torture/basic/dir.c
@@ -41,6 +41,7 @@ bool torture_dirtest1(struct torture_context *tctx,
 	bool correct = true;
 	extern int torture_numops;
 	struct timeval tv;
+	int ret;
 
 	torture_comment(tctx, "Creating %d random filenames\n", torture_numops);
 
@@ -48,7 +49,8 @@ bool torture_dirtest1(struct torture_context *tctx,
 	tv = timeval_current();
 	for (i=0;i<torture_numops;i++) {
 		char *fname;
-		asprintf(&fname, "\\%x", (int)random());
+		ret = asprintf(&fname, "\\%x", (int)random());
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
 		if (fnum == -1) {
 			fprintf(stderr,"(%s) Failed to open %s\n", 
@@ -68,7 +70,8 @@ bool torture_dirtest1(struct torture_context *tctx,
 	srandom(0);
 	for (i=0;i<torture_numops;i++) {
 		char *fname;
-		asprintf(&fname, "\\%x", (int)random());
+		ret = asprintf(&fname, "\\%x", (int)random());
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		smbcli_unlink(cli->tree, fname);
 		free(fname);
 	}
@@ -83,6 +86,7 @@ bool torture_dirtest2(struct torture_context *tctx,
 	int fnum, num_seen;
 	bool correct = true;
 	extern int torture_entries;
+	int ret;
 
 	if (!torture_setup_dir(cli, "\\LISTDIR")) {
 		return false;
@@ -93,7 +97,8 @@ bool torture_dirtest2(struct torture_context *tctx,
 	/* Create torture_entries files and torture_entries directories. */
 	for (i=0;i<torture_entries;i++) {
 		char *fname;
-		asprintf(&fname, "\\LISTDIR\\f%d", i);
+		ret = asprintf(&fname, "\\LISTDIR\\f%d", i);
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		fnum = smbcli_nt_create_full(cli->tree, fname, 0, 
 					     SEC_RIGHTS_FILE_ALL,
 					     FILE_ATTRIBUTE_ARCHIVE,
@@ -109,7 +114,8 @@ bool torture_dirtest2(struct torture_context *tctx,
 	}
 	for (i=0;i<torture_entries;i++) {
 		char *fname;
-		asprintf(&fname, "\\LISTDIR\\d%d", i);
+		ret = asprintf(&fname, "\\LISTDIR\\d%d", i);
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) {
 			fprintf(stderr,"(%s) Failed to open %s, error=%s\n", 
 				__location__, fname, smbcli_errstr(cli->tree));
-- 
2.5.5


From 20e0625441916520d609028b6edc2893b36cd8a4 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:21:17 +0200
Subject: [PATCH 26/41] s4:torture:basic:delete: fix O3 errors result of
 asprintf ignored

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/basic/delete.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c
index e3d830d..76a83df 100644
--- a/source4/torture/basic/delete.c
+++ b/source4/torture/basic/delete.c
@@ -1760,6 +1760,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
 	int dnum1 = -1;
 	bool correct = true;
 	NTSTATUS status;
+	int ret;
 
 	del_clean_area(cli1, cli2);
 
@@ -1789,7 +1790,8 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
 
 	{
 		char *fullname;
-		asprintf(&fullname, "\\%s%s", dname, fname);
+		ret = asprintf(&fullname, "\\%s%s", dname, fname);
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR,
 				    DENY_NONE);
 		torture_assert(tctx, fnum1 == -1, 
@@ -1809,7 +1811,8 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s
 		
 	{
 		char *fullname;
-		asprintf(&fullname, "\\%s%s", dname, fname);
+		ret = asprintf(&fullname, "\\%s%s", dname, fname);
+		torture_assert(tctx, ret != -1, "asprintf failed");
 		fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR,
 				    DENY_NONE);
 		torture_assert(tctx, fnum1 != -1, 
-- 
2.5.5


From 3262c42a23fcc04b417a6bf462f4b65e3bd887c6 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:33:59 +0200
Subject: [PATCH 27/41] s4:torture:rpc:samlogon: fix O3 errors result of
 asprintf ignored

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/rpc/samlogon.c | 49 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c
index 4465698..cefc4f5 100644
--- a/source4/torture/rpc/samlogon.c
+++ b/source4/torture/rpc/samlogon.c
@@ -346,8 +346,13 @@ static bool test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm
 	} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
 		return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH) || (break_which == NO_NT));
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
@@ -467,8 +472,13 @@ static bool test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_
 		}
 		return false;
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
@@ -564,8 +574,13 @@ static bool test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro
 		}
 		return false;
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
@@ -677,8 +692,13 @@ static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state,
 	} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
 		return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH) || (break_which == NO_NT));
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
@@ -845,8 +865,13 @@ static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state,
 	} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
 		return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH));
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
@@ -1126,8 +1151,13 @@ static bool test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin
 		}
 		return false;
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
@@ -1229,8 +1259,13 @@ static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea
 	} else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) {
 		return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH) || (break_which == NO_NT));
 	} else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) {
+		int ret;
+
 		SAFE_FREE(*error_string);
-		asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		ret = asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status));
+		if (ret == -1) {
+			*error_string = NULL;
+		}
 		return false;
 	} else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) {
 		return true;
-- 
2.5.5


From 02a85a85071bcbba8f946712b9260b571e9a051f Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 18:52:29 +0200
Subject: [PATCH 28/41] s4:torture:nbench: fix O3 error unused result of
 asprintf

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/torture/nbench/nbench.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c
index 3258e19..2f10435 100644
--- a/source4/torture/nbench/nbench.c
+++ b/source4/torture/nbench/nbench.c
@@ -64,6 +64,7 @@ static bool run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
 	bool correct = true;
 	double target_rate = torture_setting_double(tctx, "targetrate", 0);	
 	int n = 0;
+	int ret;
 
 	if (target_rate != 0 && client == 0) {
 		printf("Targeting %.4f MByte/sec\n", target_rate);
@@ -77,7 +78,10 @@ static bool run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
 		}
 	}
 
-	asprintf(&cname, "client%d", client+1);
+	ret = asprintf(&cname, "client%d", client+1);
+	if (ret == -1) {
+		return false;
+	}
 
 	f = fopen(loadfile, "r");
 
-- 
2.5.5


From 41d5c9c502223fe6fea956b058e2b52d70dc3888 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 19:26:41 +0200
Subject: [PATCH 29/41] s4:client: fix O3 errors unused results

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source4/client/client.c | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/source4/client/client.c b/source4/client/client.c
index a069443..4807123 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -874,6 +874,7 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
 	char *mget_mask;
 	char *saved_curdir;
 	char *l_fname;
+	int ret;
 
 	if (ISDOT(finfo->name) || ISDOTDOT(finfo->name))
 		return;
@@ -922,7 +923,11 @@ static void do_mget(struct smbclient_context *ctx, struct clilist_file_info *fin
 	mget_mask = talloc_asprintf(ctx, "%s*", ctx->remote_cur_dir);
 	
 	do_list(ctx, mget_mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,do_mget,false, true);
-	chdir("..");
+	ret = chdir("..");
+	if (ret == -1) {
+		d_printf("failed to chdir to '..': %s\n", strerror(errno));
+		return;
+	}
 	talloc_free(ctx->remote_cur_dir);
 
 	ctx->remote_cur_dir = saved_curdir;
@@ -965,7 +970,11 @@ static int cmd_more(struct smbclient_context *ctx, const char **args)
 	pager=getenv("PAGER");
 
 	pager_cmd = talloc_asprintf(ctx, "%s %s",(pager? pager:DEFAULT_PAGER), lname);
-	system(pager_cmd);
+	rc = system(pager_cmd);
+	if (rc == -1) {
+		d_printf("failed to call pager command\n");
+		return 1;
+	}
 	unlink(lname);
 	
 	return rc;
@@ -2540,8 +2549,17 @@ static int cmd_lcd(struct smbclient_context *ctx, const char **args)
 {
 	char d[PATH_MAX];
 	
-	if (args[1]) 
-		chdir(args[1]);
+	if (args[1]) {
+		int ret;
+
+		ret = chdir(args[1]);
+		if (ret == -1) {
+			d_printf("failed to chdir to dir '%s': %s\n",
+				 args[1], strerror(errno));
+			return 1;
+		}
+	}
+
 	DEBUG(2,("the local directory is now %s\n",getcwd(d, PATH_MAX)));
 
 	return 0;
@@ -3138,8 +3156,12 @@ static int process_stdin(struct smbclient_context *ctx)
 
 		/* special case - first char is ! */
 		if (*cline == '!') {
-			system(cline + 1);
+			int ret;
+			ret = system(cline + 1);
 			free(cline);
+			if (ret == -1) {
+				rc |= ret;
+			}
 			continue;
 		}
 
-- 
2.5.5


From 2f60e756d84c0244cc5127e9e7ad352b4f455245 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 19:56:25 +0200
Subject: [PATCH 30/41] s3:utils:log2pcaphex: fix O3 error unused result of
 fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/utils/log2pcaphex.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/source3/utils/log2pcaphex.c b/source3/utils/log2pcaphex.c
index 23526c2..2d68db6 100644
--- a/source3/utils/log2pcaphex.c
+++ b/source3/utils/log2pcaphex.c
@@ -350,7 +350,13 @@ int main(int argc, const char **argv)
 	if(!hexformat)print_pcap_header(out);
 
 	while(!feof(in)) {
-		fgets(buffer, sizeof(buffer), in); line_num++;
+		char *p;
+		p = fgets(buffer, sizeof(buffer), in);
+		if (p == NULL) {
+			fprintf(stderr, "error reading from input file\n");
+			break;
+		}
+		line_num++;
 		if(buffer[0] == '[') { /* Header */
 			if(strstr(buffer, "show_msg")) {
 				in_packet++;
-- 
2.5.5


From 7c9fa3823f6a6d2f36efddfb60eefad7e3cd62d1 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 19:57:42 +0200
Subject: [PATCH 31/41] s3:utils:log2pcaphex: fix O3 error uninitialized
 variable

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/utils/log2pcaphex.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source3/utils/log2pcaphex.c b/source3/utils/log2pcaphex.c
index 2d68db6..f31efa1 100644
--- a/source3/utils/log2pcaphex.c
+++ b/source3/utils/log2pcaphex.c
@@ -302,7 +302,8 @@ int main(int argc, const char **argv)
 	int opt;
 	poptContext pc;
 	char buffer[4096];
-	long data_offset, data_length;
+	long data_offset = 0;
+	long data_length;
 	long data_bytes_read = 0;
 	int in_packet = 0;
 	struct poptOption long_options[] = {
-- 
2.5.5


From 012a42fee9fa9a2933479b777e3c6865870bf7ed Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 20:01:32 +0200
Subject: [PATCH 32/41] s3:smbfilter: fix O3 error unused return of system()

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/utils/smbfilter.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
index 9068448..5a00a40 100644
--- a/source3/utils/smbfilter.c
+++ b/source3/utils/smbfilter.c
@@ -88,6 +88,7 @@ static void filter_request(char *buf, size_t buf_len)
 	int name_len1 = 0;
 	int name_len2;
 	int name_type1, name_type2;
+	int ret;
 
 	if (msg_type) {
 		/* it's a netbios special */
@@ -142,7 +143,10 @@ static void filter_request(char *buf, size_t buf_len)
 		x = IVAL(buf,smb_vwv11);
 		d_printf("SMBsesssetupX cap=0x%08x\n", x);
 		d_printf("pwlen=%d/%d\n", SVAL(buf, smb_vwv7), SVAL(buf, smb_vwv8));
-		system("mv sessionsetup.dat sessionsetup1.dat");
+		ret = system("mv sessionsetup.dat sessionsetup1.dat");
+		if (ret == -1) {
+			DBG_ERR("failed to call mv command\n");
+		}
 		save_file("sessionsetup.dat", smb_buf(buf), SVAL(buf, smb_vwv7));
 		x = (x | CLI_CAPABILITY_SET) & ~CLI_CAPABILITY_MASK;
 		SIVAL(buf, smb_vwv11, x);
-- 
2.5.5


From 5012fb8aabbd1370595219415db23f52e3c71939 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:21:19 +0200
Subject: [PATCH 33/41] s3:vfs:aio_fork: fix O3 error unused result of write

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/modules/vfs_aio_fork.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index e699fc5..7d06b98 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -411,7 +411,7 @@ static int aio_child_destructor(struct aio_child *child)
 	 * closing the sockfd makes the child not return from recvmsg() on RHEL
 	 * 5.5 so instead force the child to exit by writing bad data to it
 	 */
-	write(child->sockfd, &c, sizeof(c));
+	sys_write_v(child->sockfd, &c, sizeof(c));
 	close(child->sockfd);
 	DLIST_REMOVE(child->list->children, child);
 	return 0;
-- 
2.5.5


From 372047cf388eb1635b2077227b562f81bddcd102 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:22:47 +0200
Subject: [PATCH 34/41] s3:vfs:preopen: fix O3 error unused result of write

(void) cast is not enough.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/modules/vfs_preopen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
index b67aad8..8bf30b6 100644
--- a/source3/modules/vfs_preopen.c
+++ b/source3/modules/vfs_preopen.c
@@ -21,6 +21,7 @@
 #include "includes.h"
 #include "system/filesys.h"
 #include "smbd/smbd.h"
+#include "lib/util/sys_rw.h"
 #include "lib/util/sys_rw_data.h"
 
 struct preopen_state;
@@ -185,7 +186,7 @@ static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
 	close(fd);
 
  done:
-	(void)write(sock_fd, &c, 1);
+	sys_write_v(sock_fd, &c, 1);
 	return true;
 }
 
-- 
2.5.5


From 02f8d3646234b5dc7de26f011d81545b8ece7236 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:34:32 +0200
Subject: [PATCH 35/41] examples:smbclient:testacl3: fix O3 error unused result
 from fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 examples/libsmbclient/testacl3.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/libsmbclient/testacl3.c b/examples/libsmbclient/testacl3.c
index f34e273..59d9994 100644
--- a/examples/libsmbclient/testacl3.c
+++ b/examples/libsmbclient/testacl3.c
@@ -27,7 +27,11 @@ int main(int argc, char * argv[])
     {
         fprintf(stdout, "Path: ");
         *path = '\0';
-        fgets(path, sizeof(path) - 1, stdin);
+        p = fgets(path, sizeof(path) - 1, stdin);
+	if (p == NULL) {
+		printf("Error reading from stdin\n");
+		return 1;
+	}
         if (strlen(path) == 0)
         {
             return 0;
-- 
2.5.5


From 8033fbbd24fe68b0510aeb87222e1dd6cfaf7b0b Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:36:34 +0200
Subject: [PATCH 36/41] examples:smbclient:notify: fix O3 error unused result
 from fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 examples/libsmbclient/testnotify.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/libsmbclient/testnotify.c b/examples/libsmbclient/testnotify.c
index 68513af..8760cf0 100644
--- a/examples/libsmbclient/testnotify.c
+++ b/examples/libsmbclient/testnotify.c
@@ -43,7 +43,11 @@ int main(int argc, char * argv[])
 
 	fprintf(stdout, "Path: ");
 	*path = '\0';
-	fgets(path, sizeof(path) - 1, stdin);
+	p = fgets(path, sizeof(path) - 1, stdin);
+	if (p == NULL) {
+		fprintf(stderr, "error reading from stdin\n");
+		return 1;
+	}
 	if (strlen(path) == 0) {
 		return 0;
 	}
-- 
2.5.5


From 6549d5af8e30953b32a05cebda882976eb734237 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:50:52 +0200
Subject: [PATCH 37/41] examples:smbclient:statvfs: fix O3 error unused result
 of fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 examples/libsmbclient/teststatvfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/libsmbclient/teststatvfs.c b/examples/libsmbclient/teststatvfs.c
index 2f656d5..9a8e539 100644
--- a/examples/libsmbclient/teststatvfs.c
+++ b/examples/libsmbclient/teststatvfs.c
@@ -23,7 +23,11 @@ int main(int argc, char * argv[])
     {
         fprintf(stdout, "Path: ");
         *path = '\0';
-        fgets(path, sizeof(path) - 1, stdin);
+	p = fgets(path, sizeof(path) - 1, stdin);
+	if (p == NULL) {
+		fprintf(stderr, "failed to read from stdin\n");
+		return 1;
+	}
         if (strlen(path) == 0)
         {
             return 0;
-- 
2.5.5


From 558521c1fc1596afeede0301ba3ee2f173b70e88 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:55:01 +0200
Subject: [PATCH 38/41] examples:smbclient:fstatvfs: fix O3 error unused result
 of fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 examples/libsmbclient/testfstatvfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/libsmbclient/testfstatvfs.c b/examples/libsmbclient/testfstatvfs.c
index 512563f..b2396e3 100644
--- a/examples/libsmbclient/testfstatvfs.c
+++ b/examples/libsmbclient/testfstatvfs.c
@@ -25,7 +25,11 @@ int main(int argc, char * argv[])
     {
         fprintf(stdout, "Path: ");
         *path = '\0';
-        fgets(path, sizeof(path) - 1, stdin);
+	p = fgets(path, sizeof(path) - 1, stdin);
+	if (p == NULL) {
+		fprintf(stderr, "failed to read from stdin\n");
+		return 1;
+	}
         if (strlen(path) == 0)
         {
             return 0;
-- 
2.5.5


From 8ff5a17d273796e0ba080e7b0c4052237ff8c58c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 22:57:51 +0200
Subject: [PATCH 39/41] examples:smbclient:read: fix O3 error unused result of
 fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 examples/libsmbclient/testread.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/libsmbclient/testread.c b/examples/libsmbclient/testread.c
index 87625e8..e6d9bf8 100644
--- a/examples/libsmbclient/testread.c
+++ b/examples/libsmbclient/testread.c
@@ -24,7 +24,11 @@ int main(int argc, char * argv[])
     {
         fprintf(stdout, "Path: ");
         *path = '\0';
-        fgets(path, sizeof(path) - 1, stdin);
+	p = fgets(path, sizeof(path) - 1, stdin);
+	if (p == NULL) {
+		fprintf(stderr, "failed to read from stdin\n");
+		return 1;
+	}
         if (strlen(path) == 0)
         {
             return 0;
-- 
2.5.5


From 21e280eb0e53feb1868ff28e284c7e2a1e7bec2b Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 5 Apr 2016 23:07:11 +0200
Subject: [PATCH 40/41] examples:smbclient:write: fix O3 error unused result of
 fgets

Signed-off-by: Michael Adam <obnox at samba.org>
---
 examples/libsmbclient/testwrite.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/examples/libsmbclient/testwrite.c b/examples/libsmbclient/testwrite.c
index 636cb20..1837839 100644
--- a/examples/libsmbclient/testwrite.c
+++ b/examples/libsmbclient/testwrite.c
@@ -22,14 +22,22 @@ int main(int argc, char * argv[])
     
     printf("CAUTION: This program will overwrite a file.  "
            "Press ENTER to continue.");
-    fgets(buffer, sizeof(buffer), stdin);
+    p = fgets(buffer, sizeof(buffer), stdin);
+    if (p == NULL) {
+        fprintf(stderr, "failed to read from stdin\n");
+        return 1;
+    }
            
 
     for (;;)
     {
         fprintf(stdout, "\nPath: ");
         *path = '\0';
-        fgets(path, sizeof(path) - 1, stdin);
+        p = fgets(path, sizeof(path) - 1, stdin);
+        if (p == NULL) {
+            fprintf(stderr, "failed to read from stdin\n");
+            return 1;
+        }
         if (strlen(path) == 0)
         {
             return 0;
-- 
2.5.5


From f092874bc0e7cbd6c24e81478a48c68dc12cf3b7 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Mon, 11 Apr 2016 10:23:00 +0200
Subject: [PATCH 41/41] autobuild: run the samba-o3 target by default

Signed-off-by: Michael Adam <obnox at samba.org>
---
 script/autobuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/script/autobuild.py b/script/autobuild.py
index 6b7eca2..726ce59 100755
--- a/script/autobuild.py
+++ b/script/autobuild.py
@@ -39,7 +39,7 @@ builddirs = {
     "retry"   : "."
     }
 
-defaulttasks = [ "ctdb", "samba", "samba-xc", "samba-ctdb", "samba-libs", "samba-static", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
+defaulttasks = [ "ctdb", "samba", "samba-xc", "samba-o3", "samba-ctdb", "samba-libs", "samba-static", "ldb", "tdb", "talloc", "replace", "tevent", "pidl" ]
 
 samba_configure_params = " --picky-developer ${PREFIX} ${EXTRA_PYTHON} --with-profiling-data"
 
-- 
2.5.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160411/34fe2ec8/signature.sig>


More information about the samba-technical mailing list