[SCM] Samba Shared Repository - branch master updated

Matthias Dieter Wallnöfer mdw at samba.org
Wed Feb 9 11:45:02 MST 2011


The branch, master has been updated
       via  be80812 s4:WAF build - remove "source4/configure.developer"
       via  8d80225 ldb:tools - return LDB_ERR_OPERATIONS_ERROR on generic errors
       via  5e06b21 ldb:tools - always check if ldb connection has been estabilished
       via  22f4030 ldb:ldbsearch tool - use LDB result constants where possible
       via  23c0ae7 ldb:ldbsearch tool - simplify error code return
       via  ff7dff6 ldb:ldbsearch tool - use "%u" for printing unsigned integers
       via  475ea1c ldb:ldbedit tool - don't forget about the "do_edit" result code
       via  79d3532 ldb:ldbedit tool - fix bug #7914
       via  b5ccf18 ldb:ldbedit tool - use unsigned counters for consistency with other LDB tools
       via  bc675aa ldb:ldbedit tool - use "%u" for printing out unsigned integers
       via  b2c1831 ldb:ldbedit tool - use LDB result constants where needed
       via  bd727a9 ldb:ldbrename tool - use LDB result constant where needed
       via  ef0477a ldb:ldbmodify tool - use unsigned counters for consistency with other LDB tools
       via  6f52070 ldb:ldbdel tool - use LDB result constants for consistency
       via  2937e63 ldb:ldbadd tool - use LDB return codes where possible
       via  de9217b ldb:ldbadd tool - use "%u" for printing out unsigned integers
       via  c3ca0b0 ldb:ldbadd tool - use LDB result constants for consistency
      from  a0e5761 s3-waf: we check for attr in ../lib/util/script already, so we cannot set to EMPTY here.

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


- Log -----------------------------------------------------------------
commit be808123cb2b2bd050edb848bfdeaacc26ab397e
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Wed Feb 9 16:51:52 2011 +0100

    s4:WAF build - remove "source4/configure.developer"
    
    This isn't needed anymore - discussed with abartlet.
    
    Autobuild-User: Matthias Dieter Wallnöfer <mdw at samba.org>
    Autobuild-Date: Wed Feb  9 19:44:05 CET 2011 on sn-devel-104

commit 8d80225afb764e937e41e0d52586e1f038871734
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:34:44 2011 +0100

    ldb:tools - return LDB_ERR_OPERATIONS_ERROR on generic errors
    
    Use "return" when located in "main" for consistency ("exit" would do the
    same).
    
    The patchset has been discussed with Jelmer Vernooij and afterwards LDB
    maintainer Simo Sorce.

commit 5e06b21cc1553606efaeae03504e91d811793085
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:26:12 2011 +0100

    ldb:tools - always check if ldb connection has been estabilished
    
    Otherwise return "LDB_ERR_OPERATIONS_ERROR".

commit 22f4030c303224ecc7ee28b0b93d80d27869a4a0
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:48:52 2011 +0100

    ldb:ldbsearch tool - use LDB result constants where possible

commit 23c0ae74523c5d35e0c9b41d6a7381a72bb7f6ec
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:40:27 2011 +0100

    ldb:ldbsearch tool - simplify error code return

commit ff7dff6ef06c5327f5f3b01572f6bae88e36c4df
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:51:26 2011 +0100

    ldb:ldbsearch tool - use "%u" for printing unsigned integers

commit 475ea1ca595b3f6ea5fd6476c28f21995d781529
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Sat Feb 5 13:19:56 2011 +0100

    ldb:ldbedit tool - don't forget about the "do_edit" result code
    
    Use it for computing the program exit code. The "result" has not to be
    free'd explicitly since it's a child by "ldb" which itself is child by
    "mem_ctx".

commit 79d3532f7f905afe1a48acabf75247cef6f791e3
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:48:54 2011 +0100

    ldb:ldbedit tool - fix bug #7914
    
    "modify_record" returns "-1" when failing, otherwise the number of
    modifies performed as an "unsigned int" converted to "int".
    When we get "-1" we immediately need to stop (the error message has
    already been generated by the function itself).

commit b5ccf181f55192ac199af5e377254057a876a216
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:39:42 2011 +0100

    ldb:ldbedit tool - use unsigned counters for consistency with other LDB tools

commit bc675aa391ef29a04d841778771fef1fb737cde4
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:52:33 2011 +0100

    ldb:ldbedit tool - use "%u" for printing out unsigned integers

commit b2c183133767b5c761e982558bddd2d676f9f84f
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:39:04 2011 +0100

    ldb:ldbedit tool - use LDB result constants where needed

commit bd727a967d313f0c2552c7de36b5b85e043f250a
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:38:10 2011 +0100

    ldb:ldbrename tool - use LDB result constant where needed

commit ef0477a0b92d2e46bf78446c8beb55e16ca3128b
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:37:32 2011 +0100

    ldb:ldbmodify tool - use unsigned counters for consistency with other LDB tools

commit 6f52070d9b7bf96a283d1ec952998534e5088d4e
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:36:13 2011 +0100

    ldb:ldbdel tool - use LDB result constants for consistency

commit 2937e636442984103b6c85de98203c31fe143032
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Tue Feb 1 20:37:58 2011 +0100

    ldb:ldbadd tool - use LDB return codes where possible

commit de9217beaa7fba88273f3b0b7b05497280beb796
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:34:47 2011 +0100

    ldb:ldbadd tool - use "%u" for printing out unsigned integers

commit c3ca0b05e5e8070bbc4e760591671f97a558639d
Author: Matthias Dieter Wallnöfer <mdw at samba.org>
Date:   Fri Jan 14 12:34:08 2011 +0100

    ldb:ldbadd tool - use LDB result constants for consistency

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

Summary of changes:
 source4/configure.developer       |    6 ----
 source4/lib/ldb/tools/cmdline.c   |    2 +-
 source4/lib/ldb/tools/ldbadd.c    |   23 +++++++++------
 source4/lib/ldb/tools/ldbdel.c    |   25 +++++++++-------
 source4/lib/ldb/tools/ldbedit.c   |   55 ++++++++++++++++++-------------------
 source4/lib/ldb/tools/ldbmodify.c |   20 ++++++++-----
 source4/lib/ldb/tools/ldbrename.c |    7 +++-
 source4/lib/ldb/tools/ldbsearch.c |   26 ++++++++---------
 source4/lib/ldb/tools/ldbtest.c   |    7 +++-
 9 files changed, 90 insertions(+), 81 deletions(-)
 delete mode 100755 source4/configure.developer


Changeset truncated at 500 lines:

diff --git a/source4/configure.developer b/source4/configure.developer
deleted file mode 100755
index 5033670..0000000
--- a/source4/configure.developer
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-`dirname $0`/configure -C \
-	--enable-developer \
-	--enable-socket-wrapper \
-	--enable-nss-wrapper \
-	"$@"
diff --git a/source4/lib/ldb/tools/cmdline.c b/source4/lib/ldb/tools/cmdline.c
index c5391cc..b2be54e 100644
--- a/source4/lib/ldb/tools/cmdline.c
+++ b/source4/lib/ldb/tools/cmdline.c
@@ -313,7 +313,7 @@ struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb,
 
 failed:
 	talloc_free(ret);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 	return NULL;
 }
 
diff --git a/source4/lib/ldb/tools/ldbadd.c b/source4/lib/ldb/tools/ldbadd.c
index ab456f3..a528512 100644
--- a/source4/lib/ldb/tools/ldbadd.c
+++ b/source4/lib/ldb/tools/ldbadd.c
@@ -43,7 +43,7 @@ static void usage(struct ldb_context *ldb)
 	printf("Usage: ldbadd <options> <ldif...>\n");
 	printf("Adds records to a ldb, reading ldif the specified list of files\n\n");
 	ldb_cmdline_help(ldb, "ldbadd", stdout);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 }
 
 
@@ -57,7 +57,7 @@ static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
         struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
 	if (options->controls != NULL &&  req_ctrls== NULL) {
 		printf("parsing controls failed: %s\n", ldb_errstring(ldb));
-		return -1;
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 
@@ -102,16 +102,20 @@ int main(int argc, const char **argv)
 {
 	struct ldb_context *ldb;
 	unsigned int i, count = 0;
-	int ret=0;
+	int ret = LDB_SUCCESS;
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
 	ldb = ldb_init(mem_ctx, NULL);
+	if (ldb == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
-	if (ldb_transaction_start(ldb) != 0) {
+	ret = ldb_transaction_start(ldb);
+	if (ret != LDB_SUCCESS) {
 		printf("Failed to start transaction: %s\n", ldb_errstring(ldb));
-		exit(1);
+		return ret;
 	}
 
 	if (options->argc == 0) {
@@ -123,7 +127,7 @@ int main(int argc, const char **argv)
 			f = fopen(fname, "r");
 			if (!f) {
 				perror(fname);
-				exit(1);
+				return LDB_ERR_OPERATIONS_ERROR;
 			}
 			ret = process_file(ldb, f, &count);
 			fclose(f);
@@ -131,9 +135,10 @@ int main(int argc, const char **argv)
 	}
 
 	if (count != 0) {
-		if (ldb_transaction_commit(ldb) != 0) {
+		ret = ldb_transaction_commit(ldb);
+		if (ret != LDB_SUCCESS) {
 			printf("Failed to commit transaction: %s\n", ldb_errstring(ldb));
-			exit(1);
+			return ret;
 		}
 	} else {
 		ldb_transaction_cancel(ldb);
@@ -141,7 +146,7 @@ int main(int argc, const char **argv)
 
 	talloc_free(mem_ctx);
 
-	printf("Added %d records with %d failures\n", count, failures);
+	printf("Added %u records with %u failures\n", count, failures);
 
 	return ret;
 }
diff --git a/source4/lib/ldb/tools/ldbdel.c b/source4/lib/ldb/tools/ldbdel.c
index 0b970d9..d374fa9 100644
--- a/source4/lib/ldb/tools/ldbdel.c
+++ b/source4/lib/ldb/tools/ldbdel.c
@@ -49,13 +49,13 @@ static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struc
 	struct ldb_result *res;
 	
 	ret = ldb_search(ldb, ldb, &res, dn, LDB_SCOPE_SUBTREE, attrs, "distinguishedName=*");
-	if (ret != LDB_SUCCESS) return -1;
+	if (ret != LDB_SUCCESS) return ret;
 
 	/* sort the DNs, deepest first */
 	TYPESAFE_QSORT(res->msgs, res->count, dn_cmp);
 
 	for (i = 0; i < res->count; i++) {
-		if (ldb_delete_ctrl(ldb, res->msgs[i]->dn,req_ctrls) == 0) {
+		if (ldb_delete_ctrl(ldb, res->msgs[i]->dn,req_ctrls) == LDB_SUCCESS) {
 			total++;
 		} else {
 			printf("Failed to delete '%s' - %s\n",
@@ -67,10 +67,10 @@ static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn,struc
 	talloc_free(res);
 
 	if (total == 0) {
-		return -1;
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
-	printf("Deleted %d records\n", total);
-	return 0;
+	printf("Deleted %u records\n", total);
+	return LDB_SUCCESS;
 }
 
 static void usage(struct ldb_context *ldb)
@@ -78,7 +78,7 @@ static void usage(struct ldb_context *ldb)
 	printf("Usage: ldbdel <options> <DN...>\n");
 	printf("Deletes records from a ldb\n\n");
 	ldb_cmdline_help(ldb, "ldbdel", stdout);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 }
 
 int main(int argc, const char **argv)
@@ -90,18 +90,21 @@ int main(int argc, const char **argv)
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
 	ldb = ldb_init(mem_ctx, NULL);
+	if (ldb == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
 	if (options->argc < 1) {
 		usage(ldb);
-		exit(1);
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
 	if (options->controls != NULL &&  req_ctrls== NULL) {
 		printf("parsing controls failed: %s\n", ldb_errstring(ldb));
-		return -1;
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	for (i=0;i<options->argc;i++) {
@@ -110,17 +113,17 @@ int main(int argc, const char **argv)
 		dn = ldb_dn_new(ldb, ldb, options->argv[i]);
 		if ( ! ldb_dn_validate(dn)) {
 			printf("Invalid DN format\n");
-			exit(1);
+			return LDB_ERR_OPERATIONS_ERROR;
 		}
 		if (options->recursive) {
 			ret = ldb_delete_recursive(ldb, dn,req_ctrls);
 		} else {
 			ret = ldb_delete_ctrl(ldb, dn,req_ctrls);
-			if (ret == 0) {
+			if (ret == LDB_SUCCESS) {
 				printf("Deleted 1 record\n");
 			}
 		}
-		if (ret != 0) {
+		if (ret != LDB_SUCCESS) {
 			printf("delete of '%s' failed - (%s) %s\n",
 			       ldb_dn_get_linearized(dn),
 			       ldb_strerror(ret),
diff --git a/source4/lib/ldb/tools/ldbedit.c b/source4/lib/ldb/tools/ldbedit.c
index 74e3037..6509263 100644
--- a/source4/lib/ldb/tools/ldbedit.c
+++ b/source4/lib/ldb/tools/ldbedit.c
@@ -81,7 +81,7 @@ static int modify_record(struct ldb_context *ldb,
 		ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_MODIFY, mod);
 	}
 
-	if (ldb_modify_ctrl(ldb, mod, req_ctrls) != 0) {
+	if (ldb_modify_ctrl(ldb, mod, req_ctrls) != LDB_SUCCESS) {
 		fprintf(stderr, "failed to modify %s - %s\n",
 			ldb_dn_get_linearized(msg1->dn), ldb_errstring(ldb));
 		ret = -1;
@@ -119,15 +119,15 @@ static int merge_edits(struct ldb_context *ldb,
 {
 	unsigned int i;
 	struct ldb_message *msg;
-	int ret = 0;
-	int adds=0, modifies=0, deletes=0;
+	int ret;
+	unsigned int adds=0, modifies=0, deletes=0;
 	struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
 	if (options->controls != NULL && req_ctrls == NULL) {
 		fprintf(stderr, "parsing controls failed: %s\n", ldb_errstring(ldb));
 		return -1;
 	}
 
-	if (ldb_transaction_start(ldb) != 0) {
+	if (ldb_transaction_start(ldb) != LDB_SUCCESS) {
 		fprintf(stderr, "Failed to start transaction: %s\n", ldb_errstring(ldb));
 		return -1;
 	}
@@ -139,7 +139,7 @@ static int merge_edits(struct ldb_context *ldb,
 			if (options->verbose > 0) {
 				ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_ADD, msgs2[i]);
 			}
-			if (ldb_add_ctrl(ldb, msgs2[i], req_ctrls) != 0) {
+			if (ldb_add_ctrl(ldb, msgs2[i], req_ctrls) != LDB_SUCCESS) {
 				fprintf(stderr, "failed to add %s - %s\n",
 					ldb_dn_get_linearized(msgs2[i]->dn),
 					ldb_errstring(ldb));
@@ -148,8 +148,11 @@ static int merge_edits(struct ldb_context *ldb,
 			}
 			adds++;
 		} else {
-			if (modify_record(ldb, msg, msgs2[i], req_ctrls) > 0) {
-				modifies++;
+			ret = modify_record(ldb, msg, msgs2[i], req_ctrls);
+			if (ret != -1) {
+				modifies += (unsigned int) ret;
+			} else {
+				return -1;
 			}
 		}
 	}
@@ -161,7 +164,7 @@ static int merge_edits(struct ldb_context *ldb,
 			if (options->verbose > 0) {
 				ldif_write_msg(ldb, stdout, LDB_CHANGETYPE_DELETE, msgs1[i]);
 			}
-			if (ldb_delete_ctrl(ldb, msgs1[i]->dn, req_ctrls) != 0) {
+			if (ldb_delete_ctrl(ldb, msgs1[i]->dn, req_ctrls) != LDB_SUCCESS) {
 				fprintf(stderr, "failed to delete %s - %s\n",
 					ldb_dn_get_linearized(msgs1[i]->dn),
 					ldb_errstring(ldb));
@@ -172,14 +175,14 @@ static int merge_edits(struct ldb_context *ldb,
 		}
 	}
 
-	if (ldb_transaction_commit(ldb) != 0) {
+	if (ldb_transaction_commit(ldb) != LDB_SUCCESS) {
 		fprintf(stderr, "Failed to commit transaction: %s\n", ldb_errstring(ldb));
 		return -1;
 	}
 
-	printf("# %d adds  %d modifies  %d deletes\n", adds, modifies, deletes);
+	printf("# %u adds  %u modifies  %u deletes\n", adds, modifies, deletes);
 
-	return ret;
+	return 0;
 }
 
 /*
@@ -190,11 +193,11 @@ static int save_ldif(struct ldb_context *ldb,
 {
 	unsigned int i;
 
-	fprintf(f, "# editing %d records\n", count);
+	fprintf(f, "# editing %u records\n", count);
 
 	for (i=0;i<count;i++) {
 		struct ldb_ldif ldif;
-		fprintf(f, "# record %d\n", i+1);
+		fprintf(f, "# record %u\n", i+1);
 
 		ldif.changetype = LDB_CHANGETYPE_NONE;
 		ldif.msg = msgs[i];
@@ -288,7 +291,7 @@ static void usage(struct ldb_context *ldb)
 {
 	printf("Usage: ldbedit <options> <expression> <attributes ...>\n");
 	ldb_cmdline_help(ldb, "ldbedit", stdout);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 }
 
 int main(int argc, const char **argv)
@@ -303,6 +306,9 @@ int main(int argc, const char **argv)
 	struct ldb_control **req_ctrls;
 
 	ldb = ldb_init(mem_ctx, NULL);
+	if (ldb == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -322,38 +328,31 @@ int main(int argc, const char **argv)
 		basedn = ldb_dn_new(ldb, ldb, options->basedn);
 		if ( ! ldb_dn_validate(basedn)) {
 			printf("Invalid Base DN format\n");
-			exit(1);
+			return LDB_ERR_OPERATIONS_ERROR;
 		}
 	}
 
 	req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
 	if (options->controls != NULL &&  req_ctrls== NULL) {
 		printf("parsing controls failed: %s\n", ldb_errstring(ldb));
-		return -1;
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	ret = ldb_search_ctrl(ldb, ldb, &result, basedn, options->scope, attrs, req_ctrls, "%s", expression);
 	if (ret != LDB_SUCCESS) {
 		printf("search failed - %s\n", ldb_errstring(ldb));
-		exit(1);
+		return ret;
 	}
 
 	if (result->count == 0) {
 		printf("no matching records - cannot edit\n");
-		return 0;
+		talloc_free(mem_ctx);
+		return LDB_SUCCESS;
 	}
 
-	do_edit(ldb, result->msgs, result->count, options->editor);
-
-	if (result) {
-		ret = talloc_free(result);
-		if (ret == -1) {
-			fprintf(stderr, "talloc_free failed\n");
-			exit(1);
-		}
-	}
+	ret = do_edit(ldb, result->msgs, result->count, options->editor);
 
 	talloc_free(mem_ctx);
 
-	return 0;
+	return ret == 0 ? LDB_SUCCESS : LDB_ERR_OPERATIONS_ERROR;
 }
diff --git a/source4/lib/ldb/tools/ldbmodify.c b/source4/lib/ldb/tools/ldbmodify.c
index d5252dc..1484bbf 100644
--- a/source4/lib/ldb/tools/ldbmodify.c
+++ b/source4/lib/ldb/tools/ldbmodify.c
@@ -35,7 +35,7 @@
 #include "tools/cmdline.h"
 #include "ldbutil.h"
 
-static int failures;
+static unsigned int failures;
 static struct ldb_cmdline *options;
 
 static void usage(struct ldb_context *ldb)
@@ -43,20 +43,21 @@ static void usage(struct ldb_context *ldb)
 	printf("Usage: ldbmodify <options> <ldif...>\n");
 	printf("Modifies a ldb based upon ldif change records\n\n");
 	ldb_cmdline_help(ldb, "ldbmodify", stdout);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 }
 
 /*
   process modifies for one file
 */
-static int process_file(struct ldb_context *ldb, FILE *f, int *count)
+static int process_file(struct ldb_context *ldb, FILE *f, unsigned int *count)
 {
 	struct ldb_ldif *ldif;
 	int ret = LDB_SUCCESS;
 	struct ldb_control **req_ctrls = ldb_parse_control_strings(ldb, ldb, (const char **)options->controls);
+
 	if (options->controls != NULL &&  req_ctrls== NULL) {
 		printf("parsing controls failed: %s\n", ldb_errstring(ldb));
-		return -1;
+		exit(LDB_ERR_OPERATIONS_ERROR);
 	}
 
 	while ((ldif = ldb_ldif_read_file(ldb, f))) {
@@ -92,11 +93,14 @@ static int process_file(struct ldb_context *ldb, FILE *f, int *count)
 int main(int argc, const char **argv)
 {
 	struct ldb_context *ldb;
-	int count=0;
-	int i, ret=LDB_SUCCESS;
+	unsigned int i, count = 0;
+	int ret = LDB_SUCCESS;
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
 	ldb = ldb_init(mem_ctx, NULL);
+	if (ldb == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -109,7 +113,7 @@ int main(int argc, const char **argv)
 			f = fopen(fname, "r");
 			if (!f) {
 				perror(fname);
-				exit(1);
+				return LDB_ERR_OPERATIONS_ERROR;
 			}
 			ret = process_file(ldb, f, &count);
 			fclose(f);
@@ -118,7 +122,7 @@ int main(int argc, const char **argv)
 
 	talloc_free(mem_ctx);
 
-	printf("Modified %d records with %d failures\n", count, failures);
+	printf("Modified %u records with %u failures\n", count, failures);
 
 	return ret;
 }
diff --git a/source4/lib/ldb/tools/ldbrename.c b/source4/lib/ldb/tools/ldbrename.c
index 7473a77..0a539cc 100644
--- a/source4/lib/ldb/tools/ldbrename.c
+++ b/source4/lib/ldb/tools/ldbrename.c
@@ -41,7 +41,7 @@ static void usage(struct ldb_context *ldb)
 	printf("Usage: ldbrename [<options>] <olddn> <newdn>\n");
 	printf("Renames records in a ldb\n\n");
 	ldb_cmdline_help(ldb, "ldbmodify", stdout);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 }
 
 
@@ -54,6 +54,9 @@ int main(int argc, const char **argv)
 	TALLOC_CTX *mem_ctx = talloc_new(NULL);
 
 	ldb = ldb_init(mem_ctx, NULL);
+	if (ldb == NULL) {
+		return LDB_ERR_OPERATIONS_ERROR;
+	}
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
@@ -65,7 +68,7 @@ int main(int argc, const char **argv)
 	dn2 = ldb_dn_new(ldb, ldb, options->argv[1]);
 
 	ret = ldb_rename(ldb, dn1, dn2);
-	if (ret == 0) {
+	if (ret == LDB_SUCCESS) {
 		printf("Renamed 1 record\n");
 	} else  {
 		printf("rename of '%s' to '%s' failed - %s\n", 
diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c
index 28ec743..398710c 100644
--- a/source4/lib/ldb/tools/ldbsearch.c
+++ b/source4/lib/ldb/tools/ldbsearch.c
@@ -41,7 +41,7 @@ static void usage(struct ldb_context *ldb)
 {
 	printf("Usage: ldbsearch <options> <expression> <attrs...>\n");
 	ldb_cmdline_help(ldb, "ldbsearch", stdout);
-	exit(1);
+	exit(LDB_ERR_OPERATIONS_ERROR);
 }
 
 static int do_compare_msg(struct ldb_message **el1,
@@ -194,14 +194,14 @@ static int do_search(struct ldb_context *ldb,
 	req = NULL;
 	
 	sctx = talloc_zero(ldb, struct search_context);
-	if (!sctx) return -1;
+	if (!sctx) return LDB_ERR_OPERATIONS_ERROR;
 
 	sctx->ldb = ldb;
 	sctx->sort = options->sorted;
 	sctx->req_ctrls = ldb_parse_control_strings(ldb, sctx, (const char **)options->controls);
 	if (options->controls != NULL &&  sctx->req_ctrls== NULL) {
 		printf("parsing controls failed: %s\n", ldb_errstring(ldb));
-		return -1;
+		return LDB_ERR_OPERATIONS_ERROR;
 	}
 
 	if (basedn == NULL) {
@@ -221,7 +221,7 @@ again:
 	if (ret != LDB_SUCCESS) {
 		talloc_free(sctx);
 		printf("allocating request failed: %s\n", ldb_errstring(ldb));
-		return -1;
+		return ret;
 	}
 
 	sctx->pending = 0;
@@ -229,13 +229,13 @@ again:
 	ret = ldb_request(ldb, req);
 	if (ret != LDB_SUCCESS) {
 		printf("search failed - %s\n", ldb_errstring(ldb));
-		return -1;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list