s4:dsdb: Fix warnings about not set / set but unused / shadowed variables
[metze/samba/wip.git] / source4 / dsdb / samdb / ldb_modules / simple_ldap_map.c
index 7412d29267d19c6523ac4bc7d0f53069f428d22e..97016b5f62614a0046ad1362c38f398aca0bd772 100644 (file)
@@ -33,6 +33,7 @@
 #include "librpc/gen_ndr/ndr_misc.h"
 #include "librpc/ndr/libndr.h"
 #include "dsdb/samdb/samdb.h"
+#include "dsdb/common/util.h"
 #include <ldb_handlers.h>
 
 struct entryuuid_private {
@@ -821,7 +822,6 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque
        struct ldb_context *ldb;
        int ret;
        struct map_private *map_private;
-       struct entryuuid_private *entryuuid_private;
        unsigned long long seq_num = 0;
        struct ldb_request *search_req;
 
@@ -842,19 +842,21 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque
 
        map_private = talloc_get_type(ldb_module_get_private(module), struct map_private);
 
-       entryuuid_private = talloc_get_type(map_private->caller_private, struct entryuuid_private);
-
        /* All this to get the DN of the parition, so we can search the right thing */
        partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID);
        if (!partition_ctrl) {
                ldb_debug_set(ldb, LDB_DEBUG_FATAL,
-                             "entryuuid_sequence_number: no current partition control found");
-               return LDB_ERR_CONSTRAINT_VIOLATION;
+                             "entryuuid_sequence_number: no current partition control found!");
+               return LDB_ERR_PROTOCOL_ERROR;
        }
 
        partition = talloc_get_type(partition_ctrl->data,
                                    struct dsdb_control_current_partition);
-       SMB_ASSERT(partition && partition->version == DSDB_CONTROL_CURRENT_PARTITION_VERSION);
+       if ((partition == NULL) || (partition->version != DSDB_CONTROL_CURRENT_PARTITION_VERSION)) {
+               ldb_debug_set(ldb, LDB_DEBUG_FATAL,
+                             "entryuuid_sequence_number: current partition control with wrong data!");
+               return LDB_ERR_PROTOCOL_ERROR;
+       }
 
        ret = ldb_build_search_req(&search_req, ldb, req,
                                   partition->dn, LDB_SCOPE_BASE,
@@ -898,13 +900,10 @@ static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_reque
                seqr->seq_num++;
                break;
        case LDB_SEQ_HIGHEST_TIMESTAMP:
-       {
-               seqr->seq_num = (seq_num >> 24);
-               break;
-       }
+               return ldb_module_error(module, LDB_ERR_OPERATIONS_ERROR, "LDB_SEQ_HIGHEST_TIMESTAMP not supported");
        }
+
        seqr->flags = 0;
-       seqr->flags |= LDB_SEQ_TIMESTAMP_SEQUENCE;
        seqr->flags |= LDB_SEQ_GLOBAL_SEQUENCE;
 
        /* send request done */