[SCM] Samba Shared Repository - branch master updated

Rusty Russell rusty at samba.org
Sat Jun 9 04:08:03 MDT 2012


The branch, master has been updated
       via  36353a9 tdb2: use ccan/err instead of err.h
       via  aeb3ff5 ccan: make failtest use ccan/err.
       via  d9ce876 ccan: import err module.from ccan revision 5add556a1cb64b49a664506aa76216d885b22c97
      from  8a338c6 s3:smbd: change set_file_oplock() to return NTSTATUS

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 36353a9fc359e8156cfd2e7e4288021aba789b74
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Sat Jun 9 16:18:57 2012 +0930

    tdb2: use ccan/err instead of err.h
    
    Solaris has no err.h, so use CCAN replacement.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
    
    Autobuild-User(master): Rusty Russell <rusty at rustcorp.com.au>
    Autobuild-Date(master): Sat Jun  9 12:07:15 CEST 2012 on sn-devel-104

commit aeb3ff5c8667328f7f837412e9ec4365e3853cce
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Sat Jun 9 15:41:23 2012 +0930

    ccan: make failtest use ccan/err.
    
    As per CCAN commit 48b700953f9c856102e91596103238f5da9ea079.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

commit d9ce876ea97d59d66c8d2892b43b7cc8392470a0
Author: Rusty Russell <rusty at rustcorp.com.au>
Date:   Sat Jun 9 15:37:20 2012 +0930

    ccan: import err module.from ccan revision 5add556a1cb64b49a664506aa76216d885b22c97
    
    This allows us to avoid err.h in failtest.
    
    Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>

-----------------------------------------------------------------------

Summary of changes:
 lib/ccan/err/.depends                            |    1 +
 lib/ccan/err/_info                               |   41 ++++++
 lib/ccan/err/err.c                               |   64 +++++++++
 lib/ccan/err/err.h                               |   87 ++++++++++++
 lib/ccan/err/test/run.c                          |  153 ++++++++++++++++++++++
 lib/ccan/failtest/_info                          |    1 +
 lib/ccan/failtest/failtest.c                     |    2 +-
 lib/ccan/wscript                                 |    6 +-
 lib/tdb2/_info                                   |    2 +-
 lib/tdb2/test/api-83-openhook.c                  |    1 -
 lib/tdb2/test/external-agent.c                   |    2 +-
 lib/tdb2/test/helprun-layout.c                   |    2 +-
 lib/tdb2/test/run-30-exhaust-before-expand.c     |    1 -
 lib/tdb2/test/run-56-open-during-transaction.c   |    1 -
 lib/tdb2/test/run-57-die-during-transaction.c    |    1 -
 lib/tdb2/test/run-capabilities.c                 |    1 -
 lib/tdb2/test/run-lockall.c                      |    2 +-
 lib/tdb2/test/run-tdb1-3G-file.c                 |    1 -
 lib/tdb2/test/run-tdb1-bad-tdb-header.c          |    1 -
 lib/tdb2/test/run-tdb1-check.c                   |    1 -
 lib/tdb2/test/run-tdb1-corrupt.c                 |    1 -
 lib/tdb2/test/run-tdb1-endian.c                  |    1 -
 lib/tdb2/test/run-tdb1-hashsize.c                |    1 -
 lib/tdb2/test/run-tdb1-incompatible.c            |    1 -
 lib/tdb2/test/run-tdb1-nested-transactions.c     |    1 -
 lib/tdb2/test/run-tdb1-nested-traverse.c         |    1 -
 lib/tdb2/test/run-tdb1-no-lock-during-traverse.c |    1 -
 lib/tdb2/test/run-tdb1-oldhash.c                 |    1 -
 lib/tdb2/test/run-tdb1-readonly-check.c          |    1 -
 lib/tdb2/test/run-tdb1-rwlock-check.c            |    1 -
 lib/tdb2/test/run-tdb1-seqnum-wrap.c             |    1 -
 lib/tdb2/test/run-tdb1-summary.c                 |    1 -
 lib/tdb2/test/run-tdb1-traverse-in-transaction.c |    1 -
 lib/tdb2/test/run-tdb1-wronghash-fail.c          |    1 -
 lib/tdb2/test/run-tdb1-zero-append.c             |    1 -
 lib/tdb2/test/run-tdb1.c                         |    1 -
 lib/tdb2/test/tap-interface.h                    |    2 +-
 lib/tdb2/test/tdb1-external-agent.c              |    1 -
 lib/tdb2/tools/growtdb-bench.c                   |    2 +-
 lib/tdb2/tools/mktdb2.c                          |    2 +-
 lib/tdb2/tools/speed.c                           |    2 +-
 lib/tdb2/tools/tdb2torture.c                     |    2 +-
 42 files changed, 360 insertions(+), 38 deletions(-)
 create mode 100644 lib/ccan/err/.depends
 create mode 100644 lib/ccan/err/_info
 create mode 100644 lib/ccan/err/err.c
 create mode 100644 lib/ccan/err/err.h
 create mode 100644 lib/ccan/err/test/run.c


Changeset truncated at 500 lines:

diff --git a/lib/ccan/err/.depends b/lib/ccan/err/.depends
new file mode 100644
index 0000000..ee4f1e4
--- /dev/null
+++ b/lib/ccan/err/.depends
@@ -0,0 +1 @@
+ccan/compiler
diff --git a/lib/ccan/err/_info b/lib/ccan/err/_info
new file mode 100644
index 0000000..97bc0f9
--- /dev/null
+++ b/lib/ccan/err/_info
@@ -0,0 +1,41 @@
+#include <stdio.h>
+#include <string.h>
+#include "config.h"
+
+/**
+ * err - err(), errx(), warn() and warnx(), as per BSD's err.h.
+ *
+ * A few platforms don't provide err.h; for those, this provides replacements.
+ * For most, it simple includes the system err.h.
+ *
+ * Unfortunately, you have to call err_set_progname() to tell the replacements
+ * your program name, otherwise it prints "unknown program".
+ *
+ * Example:
+ *	#include <ccan/err/err.h>
+ *
+ *	int main(int argc, char *argv[])
+ *	{
+ *		err_set_progname(argv[0]);
+ *		if (argc != 1)
+ *			errx(1, "Expect no arguments");
+ *		exit(0);
+ *	}
+ *
+ * License: Public domain
+ * Author: Rusty Russell <rusty at rustcorp.com.au>
+ */
+int main(int argc, char *argv[])
+{
+	if (argc != 2)
+		return 1;
+
+	if (strcmp(argv[1], "depends") == 0) {
+#if !HAVE_ERR_H
+		printf("ccan/compiler\n");
+#endif
+		return 0;
+	}
+
+	return 1;
+}
diff --git a/lib/ccan/err/err.c b/lib/ccan/err/err.c
new file mode 100644
index 0000000..9e0e20c
--- /dev/null
+++ b/lib/ccan/err/err.c
@@ -0,0 +1,64 @@
+#include "err.h"
+
+#if !HAVE_ERR_H
+#include <stdarg.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+static const char *progname = "unknown program";
+
+void err_set_progname(const char *name)
+{
+	progname = name;
+}
+
+void NORETURN err(int eval, const char *fmt, ...)
+{
+	int err_errno = errno;
+	va_list ap;
+
+	fprintf(stderr, "%s: ", progname);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fprintf(stderr, ": %s\n", strerror(err_errno));
+	exit(eval);
+}
+
+void NORETURN errx(int eval, const char *fmt, ...)
+{
+	va_list ap;
+
+	fprintf(stderr, "%s: ", progname);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fprintf(stderr, "\n");
+	exit(eval);
+}
+
+void warn(const char *fmt, ...)
+{
+	int err_errno = errno;
+	va_list ap;
+
+	fprintf(stderr, "%s: ", progname);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fprintf(stderr, ": %s\n", strerror(err_errno));
+}
+
+void warnx(const char *fmt, ...)
+{
+	va_list ap;
+
+	fprintf(stderr, "%s: ", progname);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	fprintf(stderr, "\n");
+}
+#endif
diff --git a/lib/ccan/err/err.h b/lib/ccan/err/err.h
new file mode 100644
index 0000000..58ad91c
--- /dev/null
+++ b/lib/ccan/err/err.h
@@ -0,0 +1,87 @@
+#ifndef CCAN_ERR_H
+#define CCAN_ERR_H
+#include "config.h"
+
+#if HAVE_ERR_H
+#include <err.h>
+
+/* This is unnecessary with a real err.h.  See below */
+#define err_set_progname(name) ((void)name)
+
+#else
+#include <ccan/compiler/compiler.h>
+
+/**
+ * err_set_progname - set the program name
+ * @name: the name to use for err, errx, warn and warnx
+ *
+ * The BSD err.h calls know the program name, unfortunately there's no
+ * portable way for the CCAN replacements to do that on other systems.
+ *
+ * If you don't call this with argv[0], it will be "unknown program".
+ *
+ * Example:
+ *	err_set_progname(argv[0]);
+ */
+void err_set_progname(const char *name);
+
+/**
+ * err - exit(eval) with message based on format and errno.
+ * @eval: the exit code
+ * @fmt: the printf-style format string
+ *
+ * The format string is printed to stderr like so:
+ *	<executable name>: <format>: <strerror(errno)>\n
+ *
+ * Example:
+ *	char *p = strdup("hello");
+ *	if (!p)
+ *		err(1, "Failed to strdup 'hello'");
+ */
+void NORETURN err(int eval, const char *fmt, ...);
+
+/**
+ * errx - exit(eval) with message based on format.
+ * @eval: the exit code
+ * @fmt: the printf-style format string
+ *
+ * The format string is printed to stderr like so:
+ *	<executable name>: <format>\n
+ *
+ * Example:
+ *	if (argc != 1)
+ *		errx(1, "I don't expect any arguments");
+ */
+void NORETURN errx(int eval, const char *fmt, ...);
+
+/**
+ * warn - print a message to stderr based on format and errno.
+ * @eval: the exit code
+ * @fmt: the printf-style format string
+ *
+ * The format string is printed to stderr like so:
+ *	<executable name>: <format>: <strerror(errno)>\n
+ *
+ * Example:
+ *	char *p = strdup("hello");
+ *	if (!p)
+ *		warn("Failed to strdup 'hello'");
+ */
+void warn(const char *fmt, ...);
+
+/**
+ * warnx - print a message to stderr based on format.
+ * @eval: the exit code
+ * @fmt: the printf-style format string
+ *
+ * The format string is printed to stderr like so:
+ *	<executable name>: <format>\n
+ *
+ * Example:
+ *	if (argc != 1)
+ *		warnx("I don't expect any arguments (ignoring)");
+ */
+void warnx(const char *fmt, ...);
+#endif
+
+#endif /* CCAN_ERR_H */
diff --git a/lib/ccan/err/test/run.c b/lib/ccan/err/test/run.c
new file mode 100644
index 0000000..242e93f
--- /dev/null
+++ b/lib/ccan/err/test/run.c
@@ -0,0 +1,153 @@
+#include <ccan/err/err.c>
+#include <ccan/tap/tap.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#define BUFFER_MAX 1024
+
+int main(int argc, char *argv[])
+{
+	int pfd[2];
+	const char *base;
+
+	plan_tests(24);
+
+	err_set_progname(argv[0]);
+
+	/* In case it only prints out the basename of argv[0]. */
+	base = strrchr(argv[0], '/');
+	if (base)
+		base++;
+	else
+		base = argv[0];
+
+	/* Test err() in child */
+	pipe(pfd);
+	fflush(stdout);
+	if (fork()) {
+		char buffer[BUFFER_MAX+1];
+		unsigned int i;
+		int status;
+
+		/* We are parent. */
+		close(pfd[1]);
+		for (i = 0; i < BUFFER_MAX; i++) {
+			if (read(pfd[0], buffer + i, 1) == 0) {
+				buffer[i] = '\0';
+				ok1(strstr(buffer, "running err:"));
+				ok1(strstr(buffer, strerror(ENOENT)));
+				ok1(strstr(buffer, base));
+				ok1(buffer[i-1] == '\n');
+				break;
+			}
+		}
+		close(pfd[0]);
+		ok1(wait(&status) != -1);
+		ok1(WIFEXITED(status));
+		ok1(WEXITSTATUS(status) == 17);
+	} else {
+		close(pfd[0]);
+		dup2(pfd[1], STDERR_FILENO);
+		errno = ENOENT;
+		err(17, "running %s", "err");
+		abort();
+	}
+
+	/* Test errx() in child */
+	pipe(pfd);
+	fflush(stdout);
+	if (fork()) {
+		char buffer[BUFFER_MAX+1];
+		unsigned int i;
+		int status;
+
+		/* We are parent. */
+		close(pfd[1]);
+		for (i = 0; i < BUFFER_MAX; i++) {
+			if (read(pfd[0], buffer + i, 1) == 0) {
+				buffer[i] = '\0';
+				ok1(strstr(buffer, "running errx\n"));
+				ok1(strstr(buffer, base));
+				break;
+			}
+		}
+		close(pfd[0]);
+		ok1(wait(&status) != -1);
+		ok1(WIFEXITED(status));
+		ok1(WEXITSTATUS(status) == 17);
+	} else {
+		close(pfd[0]);
+		dup2(pfd[1], STDERR_FILENO);
+		errx(17, "running %s", "errx");
+		abort();
+	}
+
+
+	/* Test warn() in child */
+	pipe(pfd);
+	fflush(stdout);
+	if (fork()) {
+		char buffer[BUFFER_MAX+1];
+		unsigned int i;
+		int status;
+
+		/* We are parent. */
+		close(pfd[1]);
+		for (i = 0; i < BUFFER_MAX; i++) {
+			if (read(pfd[0], buffer + i, 1) == 0) {
+				buffer[i] = '\0';
+				ok1(strstr(buffer, "running warn:"));
+				ok1(strstr(buffer, strerror(ENOENT)));
+				ok1(strstr(buffer, base));
+				ok1(buffer[i-1] == '\n');
+				break;
+			}
+		}
+		close(pfd[0]);
+		ok1(wait(&status) != -1);
+		ok1(WIFEXITED(status));
+		ok1(WEXITSTATUS(status) == 17);
+	} else {
+		close(pfd[0]);
+		dup2(pfd[1], STDERR_FILENO);
+		errno = ENOENT;
+		warn("running %s", "warn");
+		exit(17);
+	}
+
+	/* Test warnx() in child */
+	pipe(pfd);
+	fflush(stdout);
+	if (fork()) {
+		char buffer[BUFFER_MAX+1];
+		unsigned int i;
+		int status;
+
+		/* We are parent. */
+		close(pfd[1]);
+		for (i = 0; i < BUFFER_MAX; i++) {
+			if (read(pfd[0], buffer + i, 1) == 0) {
+				buffer[i] = '\0';
+				ok1(strstr(buffer, "running warnx\n"));
+				ok1(strstr(buffer, base));
+				break;
+			}
+		}
+		close(pfd[0]);
+		ok1(wait(&status) != -1);
+		ok1(WIFEXITED(status));
+		ok1(WEXITSTATUS(status) == 17);
+	} else {
+		close(pfd[0]);
+		dup2(pfd[1], STDERR_FILENO);
+		warnx("running %s", "warnx");
+		exit(17);
+	}
+	return exit_status();
+}
+
diff --git a/lib/ccan/failtest/_info b/lib/ccan/failtest/_info
index ac9b09a..da65bcb 100644
--- a/lib/ccan/failtest/_info
+++ b/lib/ccan/failtest/_info
@@ -66,6 +66,7 @@ int main(int argc, char *argv[])
 	if (strcmp(argv[1], "depends") == 0) {
 		printf("ccan/build_assert\n");
 		printf("ccan/compiler\n");
+		printf("ccan/err\n");
 		printf("ccan/hash\n");
 		printf("ccan/htable\n");
 		printf("ccan/list\n");
diff --git a/lib/ccan/failtest/failtest.c b/lib/ccan/failtest/failtest.c
index a4a374f..ce92758 100644
--- a/lib/ccan/failtest/failtest.c
+++ b/lib/ccan/failtest/failtest.c
@@ -5,7 +5,6 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <ctype.h>
-#include <err.h>
 #include <unistd.h>
 #include <poll.h>
 #include <errno.h>
@@ -17,6 +16,7 @@
 #include <sys/resource.h>
 #include <signal.h>
 #include <assert.h>
+#include <ccan/err/err.h>
 #include <ccan/time/time.h>
 #include <ccan/read_write_all/read_write_all.h>
 #include <ccan/failtest/failtest_proto.h>
diff --git a/lib/ccan/wscript b/lib/ccan/wscript
index 8a2b3e7..8d5782a 100644
--- a/lib/ccan/wscript
+++ b/lib/ccan/wscript
@@ -122,17 +122,17 @@ def configure(conf):
 
 def build(bld):
 
-    for ccan_dir in ["hash", "htable", "ilog", "likely", "list", "read_write_all", "str", "tally", "time"]:
+    for ccan_dir in ["err", "hash", "htable", "ilog", "likely", "list", "read_write_all", "str", "tally", "time"]:
         bld.SAMBA_SUBSYSTEM('ccan-%s' % ccan_dir,
                             source=bld.path.ant_glob('%s/*.c' % ccan_dir))
 
     if bld.env.DEVELOPER_MODE:
         bld.SAMBA_LIBRARY('ccan-failtest',
                           source=bld.path.ant_glob('failtest/*.c'),
-                          deps='execinfo ccan ccan-failtest ccan-htable ccan-list ccan-read_write_all ccan-time',
+                          deps='execinfo ccan ccan-htable ccan-list ccan-read_write_all ccan-time',
                           private_library=True)
 
     bld.SAMBA_LIBRARY('ccan',
                       source='',
-                      deps='ccan-hash ccan-ilog ccan-likely ccan-tally',
+                      deps='ccan-err ccan-hash ccan-ilog ccan-likely ccan-tally',
                       private_library=True)
diff --git a/lib/tdb2/_info b/lib/tdb2/_info
index 7213d67..37c0c29 100644
--- a/lib/tdb2/_info
+++ b/lib/tdb2/_info
@@ -11,7 +11,7 @@
  * Example:
  *	#include <ccan/tdb2/tdb2.h>
  *	#include <ccan/str/str.h>
- *	#include <err.h>
+ *	#include <ccan/err/err.h>
  *	#include <stdio.h>
  *
  *	static void usage(const char *argv0)
diff --git a/lib/tdb2/test/api-83-openhook.c b/lib/tdb2/test/api-83-openhook.c
index 1ee745f..acafca7 100644
--- a/lib/tdb2/test/api-83-openhook.c
+++ b/lib/tdb2/test/api-83-openhook.c
@@ -7,7 +7,6 @@
 #include <stdlib.h>
 #include <stdbool.h>
 #include <stdarg.h>
-#include <err.h>
 #include <unistd.h>
 #include "external-agent.h"
 #include "logging.h"
diff --git a/lib/tdb2/test/external-agent.c b/lib/tdb2/test/external-agent.c
index 9d50e8f..e8cff95 100644
--- a/lib/tdb2/test/external-agent.c
+++ b/lib/tdb2/test/external-agent.c
@@ -4,7 +4,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
-#include <err.h>
+#include <ccan/err/err.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <limits.h>
diff --git a/lib/tdb2/test/helprun-layout.c b/lib/tdb2/test/helprun-layout.c
index 0bce5dd..3e56d0e 100644
--- a/lib/tdb2/test/helprun-layout.c
+++ b/lib/tdb2/test/helprun-layout.c
@@ -3,7 +3,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
-#include <err.h>
+#include <ccan/err/err.h>
 #include "logging.h"
 
 struct tdb_layout *new_tdb_layout(void)
diff --git a/lib/tdb2/test/run-30-exhaust-before-expand.c b/lib/tdb2/test/run-30-exhaust-before-expand.c
index 12449a1..c39f059 100644
--- a/lib/tdb2/test/run-30-exhaust-before-expand.c
+++ b/lib/tdb2/test/run-30-exhaust-before-expand.c
@@ -1,6 +1,5 @@
 #include "tdb2-source.h"
 #include "tap-interface.h"
-#include <err.h>
 #include "logging.h"
 
 static bool empty_freetable(struct tdb_context *tdb)
diff --git a/lib/tdb2/test/run-56-open-during-transaction.c b/lib/tdb2/test/run-56-open-during-transaction.c
index 1ac9701..f6fd36f 100644
--- a/lib/tdb2/test/run-56-open-during-transaction.c
+++ b/lib/tdb2/test/run-56-open-during-transaction.c
@@ -16,7 +16,6 @@ static int ftruncate_check(int fd, off_t length);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list