From faed8175063b16df94d5332581baf1af0562bb09 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 13 Aug 2006 07:33:57 +0000 Subject: r17514: Simplify the way to set ldb errors and add another helper function to set them. (This used to be commit 260868bae56194fcb98d55afc22fc66d96a303df) --- source4/lib/ldb/modules/asq.c | 12 ++++++------ source4/lib/ldb/modules/ldb_map.c | 2 +- source4/lib/ldb/modules/objectclass.c | 28 ++++++++++++++-------------- source4/lib/ldb/modules/operational.c | 2 +- source4/lib/ldb/modules/paged_results.c | 10 +++++----- source4/lib/ldb/modules/sort.c | 9 +++++---- 6 files changed, 32 insertions(+), 31 deletions(-) (limited to 'source4/lib/ldb/modules') diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c index 110470c8bb..1185cd8dac 100644 --- a/source4/lib/ldb/modules/asq.c +++ b/source4/lib/ldb/modules/asq.c @@ -72,7 +72,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, h = talloc_zero(mem_ctx, struct ldb_handle); if (h == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); return NULL; } @@ -80,7 +80,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, ac = talloc_zero(h, struct asq_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); talloc_free(h); return NULL; } @@ -154,7 +154,7 @@ static int asq_base_callback(struct ldb_context *ldb, void *context, struct ldb_ struct asq_context *ac; if (!context || !ares) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); + ldb_set_errstring(ldb, "NULL Context or Result in callback"); goto error; } @@ -178,7 +178,7 @@ static int asq_reqs_callback(struct ldb_context *ldb, void *context, struct ldb_ struct asq_context *ac; if (!context || !ares) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); + ldb_set_errstring(ldb, "NULL Context or Result in callback"); goto error; } @@ -220,8 +220,8 @@ static int asq_search(struct ldb_module *module, struct ldb_request *req) req->handle = NULL; if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, - "Async interface called with NULL callback function or NULL context")); + ldb_set_errstring(module->ldb, + "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/lib/ldb/modules/ldb_map.c b/source4/lib/ldb/modules/ldb_map.c index 4a21defc2b..33d8fe0e4d 100644 --- a/source4/lib/ldb/modules/ldb_map.c +++ b/source4/lib/ldb/modules/ldb_map.c @@ -827,7 +827,7 @@ static int map_search_mp(struct ldb_module *module, struct ldb_request *req) talloc_free(newattrs); if (mpret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb))); + ldb_set_errstring(module->ldb, ldb_errstring(privdat->mapped_ldb)); return mpret; } diff --git a/source4/lib/ldb/modules/objectclass.c b/source4/lib/ldb/modules/objectclass.c index a8c99226cd..9f9e8dadae 100644 --- a/source4/lib/ldb/modules/objectclass.c +++ b/source4/lib/ldb/modules/objectclass.c @@ -63,7 +63,7 @@ static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_mod h = talloc_zero(req, struct ldb_handle); if (h == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); return NULL; } @@ -71,7 +71,7 @@ static struct ldb_handle *oc_init_handle(struct ldb_request *req, struct ldb_mod ac = talloc_zero(h, struct oc_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); talloc_free(h); return NULL; } @@ -129,7 +129,7 @@ static int objectclass_sort(struct ldb_module *module, for (i=0; i < objectclass_element->num_values; i++) { current = talloc(mem_ctx, struct class_list); if (!current) { - ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: out of memory allocating objectclass list")); + ldb_set_errstring(module->ldb, "objectclass: out of memory allocating objectclass list"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -235,7 +235,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) /* prepare the first operation */ down_req = talloc(req, struct ldb_request); if (down_req == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!")); + ldb_set_errstring(module->ldb, "Out of memory!"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -264,7 +264,7 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) for (current = sorted; current; current = current->next) { ret = ldb_msg_add_string(msg, "objectClass", current->objectclass); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: could not re-add sorted objectclass to modify msg")); + ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); talloc_free(mem_ctx); return ret; } @@ -328,7 +328,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req /* prepare the first operation */ down_req = talloc(req, struct ldb_request); if (down_req == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!")); + ldb_set_errstring(module->ldb, "Out of memory!"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -362,7 +362,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req for (current = sorted; current; current = current->next) { ret = ldb_msg_add_string(msg, "objectClass", current->objectclass); if (ret != LDB_SUCCESS) { - ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "objectclass: could not re-add sorted objectclass to modify msg")); + ldb_set_errstring(module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); talloc_free(mem_ctx); return ret; } @@ -404,7 +404,7 @@ static int objectclass_modify(struct ldb_module *module, struct ldb_request *req /* prepare the first operation */ ac->down_req = talloc(ac, struct ldb_request); if (ac->down_req == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module->ldb, "Out of memory!")); + ldb_set_errstring(module->ldb, "Out of memory!"); return LDB_ERR_OPERATIONS_ERROR; } @@ -425,7 +425,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_ struct oc_context *ac; if (!context || !ares) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); + ldb_set_errstring(ldb, "NULL Context or Result in callback"); return LDB_ERR_OPERATIONS_ERROR; } @@ -434,7 +434,7 @@ static int get_self_callback(struct ldb_context *ldb, void *context, struct ldb_ /* we are interested only in the single reply (base search) we receive here */ if (ares->type == LDB_REPLY_ENTRY) { if (ac->search_res != NULL) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "Too many results")); + ldb_set_errstring(ldb, "Too many results"); talloc_free(ares); return LDB_ERR_OPERATIONS_ERROR; } @@ -466,7 +466,7 @@ static int objectclass_search_self(struct ldb_handle *h) { ac->search_req->op.search.scope = LDB_SCOPE_BASE; ac->search_req->op.search.tree = ldb_parse_tree(ac->module->ldb, NULL); if (ac->search_req->op.search.tree == NULL) { - ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: Internal error producing null search")); + ldb_set_errstring(ac->module->ldb, "objectclass: Internal error producing null search"); return LDB_ERR_OPERATIONS_ERROR; } ac->search_req->op.search.attrs = attrs; @@ -511,7 +511,7 @@ static int objectclass_do_mod(struct ldb_handle *h) { /* use a new message structure */ ac->mod_req->op.mod.message = msg = ldb_msg_new(ac->mod_req); if (msg == NULL) { - ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not create new modify msg")); + ldb_set_errstring(ac->module->ldb, "objectclass: could not create new modify msg"); talloc_free(mem_ctx); return LDB_ERR_OPERATIONS_ERROR; } @@ -539,7 +539,7 @@ static int objectclass_do_mod(struct ldb_handle *h) { ret = ldb_msg_add_empty(msg, "objectClass", LDB_FLAG_MOD_REPLACE); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not clear objectclass in modify msg")); + ldb_set_errstring(ac->module->ldb, "objectclass: could not clear objectclass in modify msg"); talloc_free(mem_ctx); return ret; } @@ -548,7 +548,7 @@ static int objectclass_do_mod(struct ldb_handle *h) { for (current = sorted; current; current = current->next) { ret = ldb_msg_add_string(msg, "objectClass", current->objectclass); if (ret != LDB_SUCCESS) { - ldb_set_errstring(ac->module->ldb, talloc_asprintf(ac, "objectclass: could not re-add sorted objectclass to modify msg")); + ldb_set_errstring(ac->module->ldb, "objectclass: could not re-add sorted objectclass to modify msg"); talloc_free(mem_ctx); return ret; } diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index 7e7c8d83ad..934622eccd 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -240,7 +240,7 @@ static int operational_callback(struct ldb_context *ldb, void *context, struct l struct operational_context *ac; if (!context || !ares) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); + ldb_set_errstring(ldb, "NULL Context or Result in callback"); goto error; } diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c index 2d972b7316..ddaed38fe9 100644 --- a/source4/lib/ldb/modules/paged_results.c +++ b/source4/lib/ldb/modules/paged_results.c @@ -141,7 +141,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, h = talloc_zero(mem_ctx, struct ldb_handle); if (h == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); return NULL; } @@ -149,7 +149,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, ac = talloc_zero(h, struct paged_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); talloc_free(h); return NULL; } @@ -171,7 +171,7 @@ static int paged_search_callback(struct ldb_context *ldb, void *context, struct struct paged_context *ac = NULL; if (!context || !ares) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); + ldb_set_errstring(ldb, "NULL Context or Result in callback"); goto error; } @@ -254,8 +254,8 @@ static int paged_search(struct ldb_module *module, struct ldb_request *req) req->handle = NULL; if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, - "Async interface called with NULL callback function or NULL context")); + ldb_set_errstring(module->ldb, + "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c index 1ab034f4fb..0ae16d08ab 100644 --- a/source4/lib/ldb/modules/sort.c +++ b/source4/lib/ldb/modules/sort.c @@ -72,7 +72,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, h = talloc_zero(mem_ctx, struct ldb_handle); if (h == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); return NULL; } @@ -80,7 +80,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module, ac = talloc_zero(h, struct sort_context); if (ac == NULL) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory")); + ldb_set_errstring(module->ldb, "Out of Memory"); talloc_free(h); return NULL; } @@ -171,7 +171,7 @@ static int server_sort_search_callback(struct ldb_context *ldb, void *context, s struct sort_context *ac = NULL; if (!context || !ares) { - ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback")); + ldb_set_errstring(ldb, "NULL Context or Result in callback"); goto error; } @@ -245,7 +245,8 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req req->handle = NULL; if (!req->callback || !req->context) { - ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context")); + ldb_set_errstring(module->ldb, + "Async interface called with NULL callback function or NULL context"); return LDB_ERR_OPERATIONS_ERROR; } -- cgit