summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-11-24 10:04:39 +0100
committerMichael Adam <obnox@samba.org>2012-11-30 17:17:21 +0100
commit60192fd1004015b50e208b3da6a07bd67f9d7990 (patch)
tree74c656e56a31db83d00f9e15c58da2dc37d1daa8
parentff274bafeb223c7440f4d97e2225b954b1031259 (diff)
downloadsamba-60192fd1004015b50e208b3da6a07bd67f9d7990.tar.gz
samba-60192fd1004015b50e208b3da6a07bd67f9d7990.tar.xz
samba-60192fd1004015b50e208b3da6a07bd67f9d7990.zip
s4:dsdb/subtree_delete: do an early return and avoid some nesting
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r--source4/dsdb/samdb/ldb_modules/subtree_delete.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/subtree_delete.c b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
index d82c3ab828b..ce1b8922f35 100644
--- a/source4/dsdb/samdb/ldb_modules/subtree_delete.c
+++ b/source4/dsdb/samdb/ldb_modules/subtree_delete.c
@@ -61,34 +61,38 @@ static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
talloc_free(res);
return ret;
}
- if (res->count > 0) {
- if (ldb_request_get_control(req, LDB_CONTROL_TREE_DELETE_OID) == NULL) {
- /* Do not add any DN outputs to this error string!
- * Some MMC consoles (eg release 2000) have a strange
- * bug and prevent subtree deletes afterwards. */
- ldb_asprintf_errstring(ldb_module_get_ctx(module),
- "subtree_delete: Unable to "
- "delete a non-leaf node "
- "(it has %u children)!",
- res->count);
- talloc_free(res);
- return LDB_ERR_NOT_ALLOWED_ON_NON_LEAF;
- }
+ if (res->count == 0) {
+ talloc_free(res);
+ return ldb_next_request(module, req);
+ }
- /* we need to start from the top since other LDB modules could
- * enforce constraints (eg "objectclass" and "samldb" do so). */
- flags = DSDB_FLAG_TOP_MODULE | DSDB_TREE_DELETE;
- if (ldb_request_get_control(req, LDB_CONTROL_RELAX_OID) != NULL) {
- flags |= DSDB_MODIFY_RELAX;
- }
+ if (ldb_request_get_control(req, LDB_CONTROL_TREE_DELETE_OID) == NULL) {
+ /* Do not add any DN outputs to this error string!
+ * Some MMC consoles (eg release 2000) have a strange
+ * bug and prevent subtree deletes afterwards. */
+ ldb_asprintf_errstring(ldb_module_get_ctx(module),
+ "subtree_delete: Unable to "
+ "delete a non-leaf node "
+ "(it has %u children)!",
+ res->count);
+ talloc_free(res);
+ return LDB_ERR_NOT_ALLOWED_ON_NON_LEAF;
+ }
- for (i = 0; i < res->count; i++) {
- ret = dsdb_module_del(module, res->msgs[i]->dn, flags, req);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
+ /* we need to start from the top since other LDB modules could
+ * enforce constraints (eg "objectclass" and "samldb" do so). */
+ flags = DSDB_FLAG_TOP_MODULE | DSDB_TREE_DELETE;
+ if (ldb_request_get_control(req, LDB_CONTROL_RELAX_OID) != NULL) {
+ flags |= DSDB_MODIFY_RELAX;
+ }
+
+ for (i = 0; i < res->count; i++) {
+ ret = dsdb_module_del(module, res->msgs[i]->dn, flags, req);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
}
+
talloc_free(res);
return ldb_next_request(module, req);