dsdb: Remove dead code in partition_prep_request()
authorAndrew Bartlett <abartlet@samba.org>
Mon, 24 Feb 2020 03:43:44 +0000 (16:43 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 28 Feb 2020 03:08:46 +0000 (03:08 +0000)
The partition variable is never NULL.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/partition.c

index 77d657cd39fb49d5a511ccc90e6955db7caa941b..d44dc19320a33632a1a46e24b85d01f647c81d5d 100644 (file)
@@ -238,6 +238,7 @@ static int partition_prep_request(struct partition_context *ac,
        int ret;
        struct ldb_request *req;
        struct ldb_control *partition_ctrl = NULL;
+       void *part_data = NULL;
 
        ac->part_req = talloc_realloc(ac, ac->part_req,
                                        struct part_request,
@@ -323,42 +324,35 @@ static int partition_prep_request(struct partition_context *ac,
                }
        }
 
-       if (partition) {
-               void *part_data = partition->ctrl;
+       part_data = partition->ctrl;
 
-               ac->part_req[ac->num_requests].module = partition->module;
+       ac->part_req[ac->num_requests].module = partition->module;
 
-               if (partition_ctrl != NULL) {
-                       if (partition_ctrl->data != NULL) {
-                               part_data = partition_ctrl->data;
-                       }
-
-                       /*
-                        * If the provided current partition control is without
-                        * data then use the calculated one.
-                        */
-                       ret = ldb_request_add_control(req,
-                                                     DSDB_CONTROL_CURRENT_PARTITION_OID,
-                                                     false, part_data);
-                       if (ret != LDB_SUCCESS) {
-                               return ret;
-                       }
+       if (partition_ctrl != NULL) {
+               if (partition_ctrl->data != NULL) {
+                       part_data = partition_ctrl->data;
                }
 
-               if (req->operation == LDB_SEARCH) {
-                       /* If the search is for 'more' than this partition,
-                        * then change the basedn, so a remote LDAP server
-                        * doesn't object */
-                       if (ldb_dn_compare_base(partition->ctrl->dn,
-                                               req->op.search.base) != 0) {
-                               req->op.search.base = partition->ctrl->dn;
-                       }
+               /*
+                * If the provided current partition control is without
+                * data then use the calculated one.
+                */
+               ret = ldb_request_add_control(req,
+                                             DSDB_CONTROL_CURRENT_PARTITION_OID,
+                                             false, part_data);
+               if (ret != LDB_SUCCESS) {
+                       return ret;
                }
+       }
 
-       } else {
-               /* make sure you put the module here, or
-                * or ldb_next_request() will skip a module */
-               ac->part_req[ac->num_requests].module = ac->module;
+       if (req->operation == LDB_SEARCH) {
+               /* If the search is for 'more' than this partition,
+                * then change the basedn, so a remote LDAP server
+                * doesn't object */
+               if (ldb_dn_compare_base(partition->ctrl->dn,
+                                       req->op.search.base) != 0) {
+                       req->op.search.base = partition->ctrl->dn;
+               }
        }
 
        ac->num_requests++;