lib ldb: format rename ldb_kv_private
authorGary Lockyer <gary@catalyst.net.nz>
Thu, 19 Jul 2018 23:54:39 +0000 (11:54 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 30 Jul 2018 12:31:53 +0000 (14:31 +0200)
Tidy up the code format after the rename of ltdb_private to
ldb_kv_private

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/ldb_mdb/ldb_mdb.c
lib/ldb/ldb_tdb/ldb_cache.c
lib/ldb/ldb_tdb/ldb_index.c
lib/ldb/ldb_tdb/ldb_search.c
lib/ldb/ldb_tdb/ldb_tdb.c
lib/ldb/ldb_tdb/ldb_tdb.h
lib/ldb/tests/ldb_kv_ops_test.c

index 34e9e1e4aaa3c2b4c361aaa23f7113570083c917..3e523ba2e851722da7bf10a48948868a07b61300 100644 (file)
@@ -92,7 +92,6 @@ static int lmdb_error_at(struct ldb_context *ldb,
        return ldb_err;
 }
 
-
 static bool lmdb_transaction_active(struct ldb_kv_private *ldb_kv)
 {
        return ldb_kv->lmdb_private->txlist != NULL;
@@ -150,7 +149,8 @@ static MDB_txn *get_current_txn(struct lmdb_private *lmdb)
 
 static int lmdb_store(struct ldb_kv_private *ldb_kv,
                      struct ldb_val key,
-                     struct ldb_val data, int flags)
+                     struct ldb_val data,
+                     int flags)
 {
        struct lmdb_private *lmdb = ldb_kv->lmdb_private;
        MDB_val mdb_key;
@@ -368,8 +368,10 @@ done:
 }
 
 /* Handles only a single record */
-static int lmdb_parse_record(struct ldb_kv_private *ldb_kv, struct ldb_val key,
-                            int (*parser)(struct ldb_val key, struct ldb_val data,
+static int lmdb_parse_record(struct ldb_kv_private *ldb_kv,
+                            struct ldb_val key,
+                            int (*parser)(struct ldb_val key,
+                                          struct ldb_val data,
                                           void *private_data),
                             void *ctx)
 {
@@ -417,7 +419,8 @@ static int lmdb_parse_record(struct ldb_kv_private *ldb_kv, struct ldb_val key,
 static int lmdb_lock_read(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct lmdb_private *lmdb = ldb_kv->lmdb_private;
        pid_t pid = getpid();
 
@@ -451,9 +454,11 @@ static int lmdb_lock_read(struct ldb_module *module)
 static int lmdb_unlock_read(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
 
-       if (lmdb_transaction_active(ldb_kv) == false && ldb_kv->read_lock_count == 1) {
+       if (lmdb_transaction_active(ldb_kv) == false &&
+           ldb_kv->read_lock_count == 1) {
                struct lmdb_private *lmdb = ldb_kv->lmdb_private;
                mdb_txn_commit(lmdb->read_txn);
                lmdb->read_txn = NULL;
@@ -554,7 +559,7 @@ static const char *lmdb_errorstr(struct ldb_kv_private *ldb_kv)
        return mdb_strerror(ldb_kv->lmdb_private->error);
 }
 
-static const char * lmdb_name(struct ldb_kv_private *ldb_kv)
+static const char *lmdb_name(struct ldb_kv_private *ldb_kv)
 {
        return "lmdb";
 }
index 1a07f99e84345942b50ef36b7215bb300a26edb1..6c61e5907095088724823a031f0117cdd0147199 100644 (file)
@@ -248,11 +248,12 @@ static int ldb_kv_index_load(struct ldb_module *module,
                 * supplying its own attribute handling
                 */
                ldb_kv->cache->attribute_indexes = true;
-               ldb_kv->cache->one_level_indexes = ldb->schema.one_level_indexes;
-               ldb_kv->cache->GUID_index_attribute
-                       = ldb->schema.GUID_index_attribute;
-               ldb_kv->cache->GUID_index_dn_component
-                       = ldb->schema.GUID_index_dn_component;
+               ldb_kv->cache->one_level_indexes =
+                   ldb->schema.one_level_indexes;
+               ldb_kv->cache->GUID_index_attribute =
+                   ldb->schema.GUID_index_attribute;
+               ldb_kv->cache->GUID_index_dn_component =
+                   ldb->schema.GUID_index_dn_component;
                return 0;
        }
 
@@ -282,22 +283,21 @@ static int ldb_kv_index_load(struct ldb_module *module,
                return -1;
        }
 
-       if (ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXONE) != NULL) {
+       if (ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXONE) !=
+           NULL) {
                ldb_kv->cache->one_level_indexes = true;
        }
-       if (ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXATTR) != NULL) {
+       if (ldb_msg_find_element(ldb_kv->cache->indexlist, LTDB_IDXATTR) !=
+           NULL) {
                ldb_kv->cache->attribute_indexes = true;
        }
-       ldb_kv->cache->GUID_index_attribute
-               = ldb_msg_find_attr_as_string(ldb_kv->cache->indexlist,
-                                             LTDB_IDXGUID, NULL);
-       ldb_kv->cache->GUID_index_dn_component
-               = ldb_msg_find_attr_as_string(ldb_kv->cache->indexlist,
-                                             LTDB_IDX_DN_GUID, NULL);
+       ldb_kv->cache->GUID_index_attribute = ldb_msg_find_attr_as_string(
+           ldb_kv->cache->indexlist, LTDB_IDXGUID, NULL);
+       ldb_kv->cache->GUID_index_dn_component = ldb_msg_find_attr_as_string(
+           ldb_kv->cache->indexlist, LTDB_IDX_DN_GUID, NULL);
 
-       lmdb_subdb_version
-               = ldb_msg_find_attr_as_int(ldb_kv->cache->indexlist,
-                                          LTDB_IDX_LMDB_SUBDB, 0);
+       lmdb_subdb_version = ldb_msg_find_attr_as_int(
+           ldb_kv->cache->indexlist, LTDB_IDX_LMDB_SUBDB, 0);
 
        if (lmdb_subdb_version != 0) {
                ldb_set_errstring(ldb,
@@ -319,7 +319,8 @@ static int ldb_kv_baseinfo_init(struct ldb_module *module)
 {
        struct ldb_context *ldb;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct ldb_message *msg;
        struct ldb_message_element el;
        struct ldb_val val;
@@ -375,7 +376,8 @@ failed:
 static void ldb_kv_cache_free(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
 
        ldb_kv->sequence_number = 0;
        talloc_free(ldb_kv->cache);
@@ -399,7 +401,8 @@ int ldb_kv_cache_load(struct ldb_module *module)
 {
        struct ldb_context *ldb;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL;
        uint64_t seq;
        struct ldb_message *baseinfo = NULL, *options = NULL;
@@ -416,7 +419,8 @@ int ldb_kv_cache_load(struct ldb_module *module)
 
        if (ldb_kv->cache == NULL) {
                ldb_kv->cache = talloc_zero(ldb_kv, struct ltdb_cache);
-               if (ldb_kv->cache == NULL) goto failed;
+               if (ldb_kv->cache == NULL)
+                       goto failed;
        }
 
        baseinfo = ldb_msg_new(ldb_kv->cache);
@@ -487,12 +491,10 @@ int ldb_kv_cache_load(struct ldb_module *module)
        
        /* set flags if they do exist */
        if (r == LDB_SUCCESS) {
-               ldb_kv->check_base = ldb_msg_find_attr_as_bool(options,
-                                                            LTDB_CHECK_BASE,
-                                                            false);
-               ldb_kv->disallow_dn_filter = ldb_msg_find_attr_as_bool(options,
-                                                                    LTDB_DISALLOW_DN_FILTER,
-                                                                    false);
+               ldb_kv->check_base =
+                   ldb_msg_find_attr_as_bool(options, LTDB_CHECK_BASE, false);
+               ldb_kv->disallow_dn_filter = ldb_msg_find_attr_as_bool(
+                   options, LTDB_DISALLOW_DN_FILTER, false);
        } else {
                ldb_kv->check_base = false;
                ldb_kv->disallow_dn_filter = false;
@@ -527,8 +529,8 @@ int ldb_kv_cache_load(struct ldb_module *module)
                 * Now the attributes are loaded, set the guid_index_syntax.
                 * This can't fail, it will return a default at worst
                 */
-               a = ldb_schema_attribute_by_name(ldb,
-                                                ldb_kv->cache->GUID_index_attribute);
+               a = ldb_schema_attribute_by_name(
+                   ldb, ldb_kv->cache->GUID_index_attribute);
                ldb_kv->GUID_index_syntax = a->syntax;
        }
 
@@ -566,7 +568,8 @@ int ldb_kv_increase_sequence_number(struct ldb_module *module)
 {
        struct ldb_context *ldb;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct ldb_message *msg;
        struct ldb_message_element el[2];
        struct ldb_val val;
@@ -583,7 +586,7 @@ int ldb_kv_increase_sequence_number(struct ldb_module *module)
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       s = talloc_asprintf(msg, "%llu", ldb_kv->sequence_number+1);
+       s = talloc_asprintf(msg, "%llu", ldb_kv->sequence_number + 1);
        if (!s) {
                talloc_free(msg);
                errno = ENOMEM;
index e0a5b62827c17a19a2b34e4405ae83dc16e606d2..1c3a7a00f09120ba2816c1245d1ece7d167cd0fe 100644 (file)
@@ -191,7 +191,7 @@ static void ldb_kv_dn_list_sort(struct ldb_kv_private *ldb_kv,
 
 static unsigned ldb_kv_max_key_length(struct ldb_kv_private *ldb_kv)
 {
-       if (ldb_kv->max_key_length == 0){
+       if (ldb_kv->max_key_length == 0) {
                return UINT_MAX;
        }
        return ldb_kv->max_key_length;
@@ -200,7 +200,8 @@ static unsigned ldb_kv_max_key_length(struct ldb_kv_private *ldb_kv)
 /* enable the idxptr mode when transactions start */
 int ldb_kv_index_transaction_start(struct ldb_module *module)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        ldb_kv->idxptr = talloc_zero(ldb_kv, struct ltdb_idxptr);
        if (ldb_kv->idxptr == NULL) {
                return ldb_oom(ldb_module_get_ctx(module));
@@ -294,8 +295,8 @@ static int ldb_kv_dn_list_find_msg(struct ldb_kv_private *ldb_kv,
                v.data = discard_const_p(unsigned char, dn_str);
                v.length = strlen(dn_str);
        } else {
-               key_val = ldb_msg_find_ldb_val(msg,
-                                              ldb_kv->cache->GUID_index_attribute);
+               key_val = ldb_msg_find_ldb_val(
+                   msg, ldb_kv->cache->GUID_index_attribute);
                if (key_val == NULL) {
                        return -1;
                }
@@ -359,8 +360,7 @@ static int ldb_kv_dn_list_load(struct ldb_module *module,
        list->count = 0;
 
        /* see if we have any in-memory index entries */
-       if (ldb_kv->idxptr == NULL ||
-           ldb_kv->idxptr->itdb == NULL) {
+       if (ldb_kv->idxptr == NULL || ldb_kv->idxptr->itdb == NULL) {
                goto normal_index;
        }
 
@@ -513,7 +513,8 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
                                       "against %s for %s: too many "
                                       "values (%u > 1)",
                                       ldb_kv->cache->GUID_index_attribute,
-                                      dn_str, list->count);
+                                      dn_str,
+                                      list->count);
                TALLOC_FREE(list);
                return LDB_ERR_CONSTRAINT_VIOLATION;
        }
@@ -546,7 +547,8 @@ int ldb_kv_key_dn_from_idx(struct ldb_module *module,
                                return ret;
                        }
 
-                       ret = ldb_kv_search_key(module, ldb_kv, key, rec, flags);
+                       ret =
+                           ldb_kv_search_key(module, ldb_kv, key, rec, flags);
                        if (key.dptr != guid_key) {
                                TALLOC_FREE(key.dptr);
                        }
@@ -704,7 +706,8 @@ static int ldb_kv_dn_list_store(struct ldb_module *module,
                                struct ldb_dn *dn,
                                struct dn_list *list)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        TDB_DATA rec, key;
        int ret;
        struct dn_list *list2;
@@ -714,7 +717,8 @@ static int ldb_kv_dn_list_store(struct ldb_module *module,
        }
 
        if (ldb_kv->idxptr->itdb == NULL) {
-               ldb_kv->idxptr->itdb = tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0);
+               ldb_kv->idxptr->itdb =
+                   tdb_open(NULL, 1000, TDB_INTERNAL, O_RDWR, 0);
                if (ldb_kv->idxptr->itdb == NULL) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -770,7 +774,8 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb,
                                       void *state)
 {
        struct ldb_module *module = state;
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        struct ldb_dn *dn;
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        struct ldb_val v;
@@ -792,7 +797,8 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb,
                return -1;
        }
 
-       ldb_kv->idxptr->error = ldb_kv_dn_list_store_full(module, ldb_kv, dn, list);
+       ldb_kv->idxptr->error =
+           ldb_kv_dn_list_store_full(module, ldb_kv, dn, list);
        talloc_free(dn);
        if (ldb_kv->idxptr->error != 0) {
                return -1;
@@ -803,7 +809,8 @@ static int ldb_kv_index_traverse_store(struct tdb_context *tdb,
 /* cleanup the idxptr mode when transaction commits */
 int ldb_kv_index_transaction_commit(struct ldb_module *module)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        int ret;
 
        struct ldb_context *ldb = ldb_module_get_ctx(module);
@@ -832,7 +839,8 @@ int ldb_kv_index_transaction_commit(struct ldb_module *module)
 /* cleanup the idxptr mode when transaction cancels */
 int ldb_kv_index_transaction_cancel(struct ldb_module *module)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        if (ldb_kv->idxptr && ldb_kv->idxptr->itdb) {
                tdb_close(ldb_kv->idxptr->itdb);
        }
@@ -1041,8 +1049,7 @@ static bool ldb_kv_is_indexed(struct ldb_module *module,
        struct ldb_message_element *el;
 
        if ((ldb_kv->cache->GUID_index_attribute != NULL) &&
-           (ldb_attr_cmp(attr,
-                         ldb_kv->cache->GUID_index_attribute) == 0)) {
+           (ldb_attr_cmp(attr, ldb_kv->cache->GUID_index_attribute) == 0)) {
                /* Implicity covered, this is the index key */
                return false;
        }
@@ -1136,10 +1143,10 @@ static int ldb_kv_index_dn_simple(struct ldb_module *module,
        return ret;
 }
 
-
 static bool list_union(struct ldb_context *ldb,
                       struct ldb_kv_private *ldb_kv,
-                      struct dn_list *list, struct dn_list *list2);
+                      struct dn_list *list,
+                      struct dn_list *list2);
 
 /*
   return a list of dn's that might match a leaf indexed search
@@ -1205,10 +1212,8 @@ static int ldb_kv_index_dn_leaf(struct ldb_module *module,
                 * ensure we get the index in binary, rather
                 * than a string
                 */
-               ret = ldb_kv->GUID_index_syntax->canonicalise_fn(ldb,
-                                                              list->dn,
-                                                              &tree->u.equality.value,
-                                                              &list->dn[0]);
+               ret = ldb_kv->GUID_index_syntax->canonicalise_fn(
+                   ldb, list->dn, &tree->u.equality.value, &list->dn[0]);
                if (ret != LDB_SUCCESS) {
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -1226,7 +1231,8 @@ static int ldb_kv_index_dn_leaf(struct ldb_module *module,
 */
 static bool list_intersect(struct ldb_context *ldb,
                           struct ldb_kv_private *ldb_kv,
-                          struct dn_list *list, const struct dn_list *list2)
+                          struct dn_list *list,
+                          const struct dn_list *list2)
 {
        const struct dn_list *short_list, *long_list;
        struct dn_list *list3;
@@ -1306,7 +1312,8 @@ static bool list_intersect(struct ldb_context *ldb,
 */
 static bool list_union(struct ldb_context *ldb,
                       struct ldb_kv_private *ldb_kv,
-                      struct dn_list *list, struct dn_list *list2)
+                      struct dn_list *list,
+                      struct dn_list *list2)
 {
        struct ldb_val *dn3;
        unsigned int i = 0, j = 0, k = 0;
@@ -1468,7 +1475,8 @@ static bool ldb_kv_index_unique(struct ldb_context *ldb,
 {
        const struct ldb_schema_attribute *a;
        if (ldb_kv->cache->GUID_index_attribute != NULL) {
-               if (ldb_attr_cmp(attr, ldb_kv->cache->GUID_index_attribute) == 0) {
+               if (ldb_attr_cmp(attr, ldb_kv->cache->GUID_index_attribute) ==
+                   0) {
                        return true;
                }
        }
@@ -1508,7 +1516,8 @@ static int ldb_kv_index_dn_and(struct ldb_module *module,
                int ret;
 
                if (subtree->operation != LDB_OP_EQUALITY ||
-                   !ldb_kv_index_unique(ldb, ldb_kv, subtree->u.equality.attr)) {
+                   !ldb_kv_index_unique(
+                       ldb, ldb_kv, subtree->u.equality.attr)) {
                        continue;
                }
 
@@ -1560,8 +1569,7 @@ static int ldb_kv_index_dn_and(struct ldb_module *module,
                        list->dn = list2->dn;
                        list->count = list2->count;
                        found = true;
-               } else if (!list_intersect(ldb, ldb_kv,
-                                          list, list2)) {
+               } else if (!list_intersect(ldb, ldb_kv, list, list2)) {
                        talloc_free(list2);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -1666,8 +1674,8 @@ static int ldb_kv_index_dn_base_dn(struct ldb_module *module,
        }
 
        if (ldb_kv->cache->GUID_index_dn_component != NULL) {
-               guid_val = ldb_dn_get_extended_component(base_dn,
-                                                        ldb_kv->cache->GUID_index_dn_component);
+               guid_val = ldb_dn_get_extended_component(
+                   base_dn, ldb_kv->cache->GUID_index_dn_component);
        }
 
        if (guid_val != NULL) {
@@ -1865,9 +1873,9 @@ static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv,
                 *
                 * LDB_SCOPE_BASE is not passed in by our only caller.
                 */
-               if (ac->scope == LDB_SCOPE_ONELEVEL
-                   && ldb_kv->cache->one_level_indexes
-                   && scope_one_truncation == KEY_NOT_TRUNCATED) {
+               if (ac->scope == LDB_SCOPE_ONELEVEL &&
+                   ldb_kv->cache->one_level_indexes &&
+                   scope_one_truncation == KEY_NOT_TRUNCATED) {
                        ret = ldb_match_message(ldb, msg, ac->tree,
                                                ac->scope, &matched);
                } else {
@@ -1916,7 +1924,8 @@ static int ldb_kv_index_filter(struct ldb_kv_private *ldb_kv,
 /*
   sort a DN list
  */
-static void ldb_kv_dn_list_sort(struct ldb_kv_private *ltdb, struct dn_list *list)
+static void ldb_kv_dn_list_sort(struct ldb_kv_private *ltdb,
+                               struct dn_list *list)
 {
        if (list->count < 2) {
                return;
@@ -1939,7 +1948,8 @@ static void ldb_kv_dn_list_sort(struct ldb_kv_private *ltdb, struct dn_list *lis
 int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(ac->module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(ac->module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(ac->module), struct ldb_kv_private);
        struct dn_list *dn_list;
        int ret;
        enum ldb_scope index_scope;
@@ -1947,8 +1957,7 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count)
 
        /* see if indexing is enabled */
        if (!ldb_kv->cache->attribute_indexes &&
-           !ldb_kv->cache->one_level_indexes &&
-           ac->scope != LDB_SCOPE_BASE) {
+           !ldb_kv->cache->one_level_indexes && ac->scope != LDB_SCOPE_BASE) {
                /* fallback to a full search */
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -1984,8 +1993,11 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count)
                 * the tree, we must ensure we strictly intersect with
                 * this list, as we trust the ONELEVEL index
                 */
-               ret = ldb_kv_index_dn_one(
-                   ac->module, ldb_kv, ac->base, dn_list, &scope_one_truncation);
+               ret = ldb_kv_index_dn_one(ac->module,
+                                         ldb_kv,
+                                         ac->base,
+                                         dn_list,
+                                         &scope_one_truncation);
                if (ret != LDB_SUCCESS) {
                        talloc_free(dn_list);
                        return ret;
@@ -2026,7 +2038,8 @@ int ldb_kv_search_indexed(struct ldb_kv_context *ac, uint32_t *match_count)
                        ret = ldb_kv_index_dn(
                            ac->module, ldb_kv, ac->tree, idx_one_tree_list);
                        if (ret == LDB_SUCCESS) {
-                               if (!list_intersect(ldb, ldb_kv,
+                               if (!list_intersect(ldb,
+                                                   ldb_kv,
                                                    dn_list,
                                                    idx_one_tree_list)) {
                                        talloc_free(idx_one_tree_list);
@@ -2130,12 +2143,12 @@ static int ldb_kv_index_add1(struct ldb_module *module,
                (el->flags & LDB_FLAG_INTERNAL_FORCE_UNIQUE_INDEX)))) {
 
                ldb_asprintf_errstring(
-                       ldb,
-                       __location__ ": unique index key on %s in %s, "
-                       "exceeds maximum key length of %u (encoded).",
-                       el->name,
-                       ldb_dn_get_linearized(msg->dn),
-                       ldb_kv->max_key_length);
+                   ldb,
+                   __location__ ": unique index key on %s in %s, "
+                                "exceeds maximum key length of %u (encoded).",
+                   el->name,
+                   ldb_dn_get_linearized(msg->dn),
+                   ldb_kv->max_key_length);
                talloc_free(list);
                return LDB_ERR_CONSTRAINT_VIOLATION;
        }
@@ -2191,7 +2204,8 @@ static int ldb_kv_index_add1(struct ldb_module *module,
                                return ret;
                        }
 
-                       ret = ldb_kv_search_key(module, ldb_kv, key, rec, flags);
+                       ret =
+                           ldb_kv_search_key(module, ldb_kv, key, rec, flags);
                        if (key.dptr != guid_key) {
                                TALLOC_FREE(key.dptr);
                        }
@@ -2251,15 +2265,15 @@ static int ldb_kv_index_add1(struct ldb_module *module,
                                  ldb_dn_get_linearized(dn_key));
                } else {
                        /* This can't fail, gives a default at worst */
-                       const struct ldb_schema_attribute *attr
-                               = ldb_schema_attribute_by_name(
-                                       ldb,
-                                       ldb_kv->cache->GUID_index_attribute);
+                       const struct ldb_schema_attribute *attr =
+                           ldb_schema_attribute_by_name(
+                               ldb, ldb_kv->cache->GUID_index_attribute);
                        struct ldb_val v;
                        ret = attr->syntax->ldif_write_fn(ldb, list,
                                                          &list->dn[0], &v);
                        if (ret == LDB_SUCCESS) {
-                               ldb_debug(ldb, LDB_DEBUG_WARNING,
+                               ldb_debug(ldb,
+                                         LDB_DEBUG_WARNING,
                                          __location__
                                          ": unique index violation on %s in "
                                          "%s, conficts with %s %*.*s in %s",
@@ -2302,8 +2316,8 @@ static int ldb_kv_index_add1(struct ldb_module *module,
        } else {
                const struct ldb_val *key_val;
                struct ldb_val *exact = NULL, *next = NULL;
-               key_val = ldb_msg_find_ldb_val(msg,
-                                              ldb_kv->cache->GUID_index_attribute);
+               key_val = ldb_msg_find_ldb_val(
+                   msg, ldb_kv->cache->GUID_index_attribute);
                if (key_val == NULL) {
                        talloc_free(list);
                        return ldb_module_operr(module);
@@ -2326,15 +2340,15 @@ static int ldb_kv_index_add1(struct ldb_module *module,
                 */
                if (exact != NULL && truncation == KEY_NOT_TRUNCATED) {
                        /* This can't fail, gives a default at worst */
-                       const struct ldb_schema_attribute *attr
-                               = ldb_schema_attribute_by_name(
-                                       ldb,
-                                       ldb_kv->cache->GUID_index_attribute);
+                       const struct ldb_schema_attribute *attr =
+                           ldb_schema_attribute_by_name(
+                               ldb, ldb_kv->cache->GUID_index_attribute);
                        struct ldb_val v;
                        ret = attr->syntax->ldif_write_fn(ldb, list,
                                                          exact, &v);
                        if (ret == LDB_SUCCESS) {
-                               ldb_debug(ldb, LDB_DEBUG_WARNING,
+                               ldb_debug(ldb,
+                                         LDB_DEBUG_WARNING,
                                          __location__
                                          ": duplicate attribute value in %s "
                                          "for index on %s, "
@@ -2457,10 +2471,9 @@ static int ldb_kv_modify_index_dn(struct ldb_module *module,
        if (val.data == NULL) {
                const char *dn_str = ldb_dn_get_linearized(dn);
                ldb_asprintf_errstring(ldb_module_get_ctx(module),
-                                      __location__
-                                      ": Failed to modify %s "
-                                      "against %s in %s: failed "
-                                      "to get casefold DN",
+                                      __location__ ": Failed to modify %s "
+                                                   "against %s in %s: failed "
+                                                   "to get casefold DN",
                                       index,
                                       ldb_kv->cache->GUID_index_attribute,
                                       dn_str);
@@ -2482,12 +2495,12 @@ static int ldb_kv_modify_index_dn(struct ldb_module *module,
                struct ldb_context *ldb = ldb_module_get_ctx(module);
                const char *dn_str = ldb_dn_get_linearized(dn);
                ldb_asprintf_errstring(ldb,
-                                      __location__
-                                      ": Failed to modify %s "
-                                      "against %s in %s - %s",
+                                      __location__ ": Failed to modify %s "
+                                                   "against %s in %s - %s",
                                       index,
                                       ldb_kv->cache->GUID_index_attribute,
-                                      dn_str, ldb_errstring(ldb));
+                                      dn_str,
+                                      ldb_errstring(ldb));
                return ret;
        }
        return ret;
@@ -2500,8 +2513,8 @@ static int ldb_kv_index_onelevel(struct ldb_module *module,
                                 const struct ldb_message *msg,
                                 int add)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module),
-                                                   struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        struct ldb_dn *pdn;
        int ret;
 
@@ -2514,7 +2527,8 @@ static int ldb_kv_index_onelevel(struct ldb_module *module,
        if (pdn == NULL) {
                return LDB_ERR_OPERATIONS_ERROR;
        }
-       ret = ldb_kv_modify_index_dn(module, ldb_kv, msg, pdn, LTDB_IDXONE, add);
+       ret =
+           ldb_kv_modify_index_dn(module, ldb_kv, msg, pdn, LTDB_IDXONE, add);
 
        talloc_free(pdn);
 
@@ -2529,16 +2543,16 @@ static int ldb_kv_write_index_dn_guid(struct ldb_module *module,
                                      int add)
 {
        int ret;
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module),
-                                                   struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
 
        /* We index for DN only if using a GUID index */
        if (ldb_kv->cache->GUID_index_attribute == NULL) {
                return LDB_SUCCESS;
        }
 
-       ret =
-           ldb_kv_modify_index_dn(module, ldb_kv, msg, msg->dn, LTDB_IDXDN, add);
+       ret = ldb_kv_modify_index_dn(
+           module, ldb_kv, msg, msg->dn, LTDB_IDXDN, add);
 
        if (ret == LDB_ERR_CONSTRAINT_VIOLATION) {
                ldb_asprintf_errstring(ldb_module_get_ctx(module),
@@ -2744,7 +2758,8 @@ int ldb_kv_index_del_element(struct ldb_module *module,
 int ldb_kv_index_delete(struct ldb_module *module,
                        const struct ldb_message *msg)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        int ret;
        unsigned int i;
 
@@ -2787,7 +2802,10 @@ int ldb_kv_index_delete(struct ldb_module *module,
   commit, which in turn greatly reduces DB churn as we will likely
   be able to do a direct update into the old record.
 */
-static int delete_index(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, void *state)
+static int delete_index(struct ldb_kv_private *ldb_kv,
+                       struct ldb_val key,
+                       struct ldb_val data,
+                       void *state)
 {
        struct ldb_module *module = state;
        const char *dnstr = "DN=" LTDB_INDEX ":";
@@ -2829,7 +2847,10 @@ static int delete_index(struct ldb_kv_private *ldb_kv, struct ldb_val key, struc
 /*
   traversal function that adds @INDEX records during a re index TODO wrong comment
 */
-static int re_key(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct ldb_val val, void *state)
+static int re_key(struct ldb_kv_private *ldb_kv,
+                 struct ldb_val ldb_key,
+                 struct ldb_val val,
+                 void *state)
 {
        struct ldb_context *ldb;
        struct ldb_kv_reindex_context *ctx =
@@ -2902,7 +2923,8 @@ static int re_key(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct
                        .data = key2.dptr,
                        .length = key2.dsize
                };
-               ldb_kv->kv_ops->update_in_iterate(ldb_kv, ldb_key, ldb_key2, val, ctx);
+               ldb_kv->kv_ops->update_in_iterate(
+                   ldb_kv, ldb_key, ldb_key2, val, ctx);
        }
        talloc_free(key2.dptr);
 
@@ -2921,7 +2943,10 @@ static int re_key(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct
 /*
   traversal function that adds @INDEX records during a re index
 */
-static int re_index(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struct ldb_val val, void *state)
+static int re_index(struct ldb_kv_private *ldb_kv,
+                   struct ldb_val ldb_key,
+                   struct ldb_val val,
+                   void *state)
 {
        struct ldb_context *ldb;
        struct ldb_kv_reindex_context *ctx =
@@ -3010,7 +3035,8 @@ static int re_index(struct ldb_kv_private *ldb_kv, struct ldb_val ldb_key, struc
 */
 int ldb_kv_reindex(struct ldb_module *module)
 {
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
        int ret;
        struct ldb_kv_reindex_context ctx;
 
@@ -3087,7 +3113,8 @@ int ldb_kv_reindex(struct ldb_module *module)
 
        if (ctx.count > 10000) {
                ldb_debug(ldb_module_get_ctx(module),
-                         LDB_DEBUG_WARNING, "Reindexing: re_index successful on %s, "
+                         LDB_DEBUG_WARNING,
+                         "Reindexing: re_index successful on %s, "
                          "final index write-out will be in transaction commit",
                          ldb_kv->kv_ops->name(ldb_kv));
        }
index fd8b64ef1b7dcd73e733698ef652cde4849a8884..b3eafeb7533671e869467f72350aef4f67d6c482 100644 (file)
@@ -289,7 +289,8 @@ int ldb_kv_search_dn1(struct ldb_module *module,
                      unsigned int unpack_flags)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        int ret;
        uint8_t guid_key[LTDB_GUID_KEY_SIZE];
        TDB_DATA tdb_key = {
@@ -299,7 +300,7 @@ int ldb_kv_search_dn1(struct ldb_module *module,
        TALLOC_CTX *tdb_key_ctx = NULL;
 
        if (ldb_kv->cache->GUID_index_attribute == NULL ||
-               ldb_dn_is_special(dn)) {
+           ldb_dn_is_special(dn)) {
 
                tdb_key_ctx = talloc_new(msg);
                if (!tdb_key_ctx) {
@@ -493,7 +494,10 @@ failed:
 /*
   search function for a non-indexed search
  */
-static int search_func(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val val, void *state)
+static int search_func(struct ldb_kv_private *ldb_kv,
+                      struct ldb_val key,
+                      struct ldb_val val,
+                      void *state)
 {
        struct ldb_context *ldb;
        struct ldb_kv_context *ac;
@@ -583,7 +587,8 @@ static int search_func(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct
 static int ldb_kv_search_full(struct ldb_kv_context *ctx)
 {
        void *data = ldb_module_get_private(ctx->module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        int ret;
 
        ctx->error = LDB_SUCCESS;
@@ -708,7 +713,8 @@ int ldb_kv_search(struct ldb_kv_context *ctx)
        struct ldb_module *module = ctx->module;
        struct ldb_request *req = ctx->req;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        int ret;
 
        ldb = ldb_module_get_ctx(module);
@@ -811,7 +817,8 @@ int ldb_kv_search(struct ldb_kv_context *ctx)
                 * callback error */
                if ( ! ctx->request_terminated && ret != LDB_SUCCESS) {
                        /* Not indexed, so we need to do a full scan */
-                       if (ldb_kv->warn_unindexed || ldb_kv->disable_full_db_scan) {
+                       if (ldb_kv->warn_unindexed ||
+                           ldb_kv->disable_full_db_scan) {
                                /* useful for debugging when slow performance
                                 * is caused by unindexed searches */
                                char *expression = ldb_filter_from_tree(ctx, ctx->tree);
index c1f5fa3488eac787a3106bcaa451819571aa9ddc..b963123bfda8e951dd3cb53f0ae3a82b67941e6d 100644 (file)
@@ -97,18 +97,19 @@ int ltdb_err_map(enum TDB_ERROR tdb_code)
 static int ltdb_lock_read(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        int tdb_ret = 0;
        int ret;
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -138,19 +139,21 @@ static int ltdb_lock_read(struct ldb_module *module)
 static int ltdb_unlock_read(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
-       if (!tdb_transaction_active(ldb_kv->tdb) && ldb_kv->read_lock_count == 1) {
+       if (!tdb_transaction_active(ldb_kv->tdb) &&
+           ldb_kv->read_lock_count == 1) {
                tdb_unlockall_read(ldb_kv->tdb);
                ldb_kv->read_lock_count--;
                return 0;
@@ -310,7 +313,8 @@ TDB_DATA ldb_kv_key_msg(struct ldb_module *module,
                        const struct ldb_message *msg)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        TDB_DATA key;
        const struct ldb_val *guid_val;
        int ret;
@@ -323,8 +327,8 @@ TDB_DATA ldb_kv_key_msg(struct ldb_module *module,
                return ldb_kv_key_dn(module, mem_ctx, msg->dn);
        }
 
-       guid_val = ldb_msg_find_ldb_val(msg,
-                                      ldb_kv->cache->GUID_index_attribute);
+       guid_val =
+           ldb_msg_find_ldb_val(msg, ldb_kv->cache->GUID_index_attribute);
        if (guid_val == NULL) {
                ldb_asprintf_errstring(ldb_module_get_ctx(module),
                                       "Did not find GUID attribute %s "
@@ -399,7 +403,8 @@ static int ldb_kv_check_special_dn(struct ldb_module *module,
 static int ldb_kv_modified(struct ldb_module *module, struct ldb_dn *dn)
 {
        int ret = LDB_SUCCESS;
-       struct ldb_kv_private *ldb_kv = talloc_get_type(ldb_module_get_private(module), struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv = talloc_get_type(
+           ldb_module_get_private(module), struct ldb_kv_private);
 
        /* only allow modifies inside a transaction, otherwise the
         * ldb is unsafe */
@@ -414,8 +419,10 @@ static int ldb_kv_modified(struct ldb_module *module, struct ldb_dn *dn)
        {
                if (ldb_kv->warn_reindex) {
                        ldb_debug(ldb_module_get_ctx(module),
-                               LDB_DEBUG_ERROR, "Reindexing %s due to modification on %s",
-                               ldb_kv->kv_ops->name(ldb_kv), ldb_dn_get_linearized(dn));
+                                 LDB_DEBUG_ERROR,
+                                 "Reindexing %s due to modification on %s",
+                                 ldb_kv->kv_ops->name(ldb_kv),
+                                 ldb_dn_get_linearized(dn));
                }
                ret = ldb_kv_reindex(module);
        }
@@ -479,7 +486,8 @@ int ldb_kv_store(struct ldb_module *module,
                 int flgs)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        TDB_DATA tdb_key;
        struct ldb_val ldb_key;
        struct ldb_val ldb_data;
@@ -520,9 +528,8 @@ int ldb_kv_store(struct ldb_module *module,
                 * LDB_ERR_ENTRY_ALREADY_EXISTS means the DN, not
                 * the GUID, so re-map
                 */
-               if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS
-                   && !is_special
-                   && ldb_kv->cache->GUID_index_attribute != NULL) {
+               if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS && !is_special &&
+                   ldb_kv->cache->GUID_index_attribute != NULL) {
                        ret = LDB_ERR_CONSTRAINT_VIOLATION;
                }
                goto done;
@@ -676,13 +683,13 @@ static int ldb_kv_add(struct ldb_kv_context *ctx)
        struct ldb_module *module = ctx->module;
        struct ldb_request *req = ctx->req;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        int ret = LDB_SUCCESS;
 
        if (ldb_kv->max_key_length != 0 &&
            ldb_kv->cache->GUID_index_attribute == NULL &&
-           !ldb_dn_is_special(req->op.add.message->dn))
-       {
+           !ldb_dn_is_special(req->op.add.message->dn)) {
                ldb_set_errstring(ldb_module_get_ctx(module),
                                  "Must operate ldb_mdb in GUID "
                                  "index mode, but " LTDB_IDXGUID " not set.");
@@ -726,7 +733,8 @@ int ldb_kv_delete_noindex(struct ldb_module *module,
                          const struct ldb_message *msg)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct ldb_val ldb_key;
        TDB_DATA tdb_key;
        int ret;
@@ -750,7 +758,7 @@ int ldb_kv_delete_noindex(struct ldb_module *module,
        ldb_key.data = tdb_key.dptr;
        ldb_key.length = tdb_key.dsize;
 
-       ret = ldb_kv->kv_ops->delete(ldb_kv, ldb_key);
+       ret = ldb_kv->kv_ops->delete (ldb_kv, ldb_key);
        TALLOC_FREE(tdb_key_ctx);
 
        if (ret != 0) {
@@ -899,11 +907,11 @@ static int ldb_kv_msg_delete_attribute(struct ldb_module *module,
        struct ldb_message_element *el;
        bool is_special = ldb_dn_is_special(msg->dn);
 
-       if (!is_special
-           && ldb_kv->cache->GUID_index_attribute != NULL
-           && ldb_attr_cmp(name, ldb_kv->cache->GUID_index_attribute) == 0) {
+       if (!is_special && ldb_kv->cache->GUID_index_attribute != NULL &&
+           ldb_attr_cmp(name, ldb_kv->cache->GUID_index_attribute) == 0) {
                struct ldb_context *ldb = ldb_module_get_ctx(module);
-               ldb_asprintf_errstring(ldb, "Must not modify GUID "
+               ldb_asprintf_errstring(ldb,
+                                      "Must not modify GUID "
                                       "attribute %s (used as DB index)",
                                       ldb_kv->cache->GUID_index_attribute);
                return LDB_ERR_CONSTRAINT_VIOLATION;
@@ -974,7 +982,8 @@ static int ldb_kv_msg_delete_element(struct ldb_module *module,
                                    module, ldb_kv, msg, name);
                        }
 
-                       ret = ldb_kv_index_del_value(module, ldb_kv, msg, el, i);
+                       ret =
+                           ldb_kv_index_del_value(module, ldb_kv, msg, el, i);
                        if (ret != LDB_SUCCESS) {
                                return ret;
                        }
@@ -1011,7 +1020,8 @@ int ldb_kv_modify_internal(struct ldb_module *module,
 {
        struct ldb_context *ldb = ldb_module_get_ctx(module);
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct ldb_message *msg2;
        unsigned int i, j;
        int ret = LDB_SUCCESS, idx;
@@ -1255,7 +1265,8 @@ int ldb_kv_modify_internal(struct ldb_module *module,
                                goto done;
                        }
 
-                       ret = ldb_kv_index_add_element(module, ldb_kv, msg2, el);
+                       ret =
+                           ldb_kv_index_add_element(module, ldb_kv, msg2, el);
                        if (ret != LDB_SUCCESS) {
                                goto done;
                        }
@@ -1272,7 +1283,10 @@ int ldb_kv_modify_internal(struct ldb_module *module,
                        if (msg->elements[i].num_values == 0) {
                                /* Delete the whole attribute */
                                ret = ldb_kv_msg_delete_attribute(
-                                   module, ldb_kv, msg2, msg->elements[i].name);
+                                   module,
+                                   ldb_kv,
+                                   msg2,
+                                   msg->elements[i].name);
                                if (ret == LDB_ERR_NO_SUCH_ATTRIBUTE &&
                                    control_permissive) {
                                        ret = LDB_SUCCESS;
@@ -1364,7 +1378,8 @@ static int ldb_kv_rename(struct ldb_kv_context *ctx)
 {
        struct ldb_module *module = ctx->module;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        struct ldb_request *req = ctx->req;
        struct ldb_message *msg;
        int ret = LDB_SUCCESS;
@@ -1476,12 +1491,12 @@ static int ltdb_transaction_start(struct ldb_kv_private *ldb_kv)
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(ldb_kv->module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(ldb_kv->module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -1493,12 +1508,12 @@ static int ltdb_transaction_cancel(struct ldb_kv_private *ldb_kv)
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(ldb_kv->module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(ldb_kv->module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -1510,12 +1525,12 @@ static int ltdb_transaction_prepare_commit(struct ldb_kv_private *ldb_kv)
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(ldb_kv->module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(ldb_kv->module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -1527,12 +1542,12 @@ static int ltdb_transaction_commit(struct ldb_kv_private *ldb_kv)
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(ldb_kv->module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(ldb_kv->module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -1542,17 +1557,18 @@ static int ltdb_transaction_commit(struct ldb_kv_private *ldb_kv)
 static int ldb_kv_start_trans(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
 
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(ldb_kv->module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(ldb_kv->module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -1582,16 +1598,17 @@ static int ldb_kv_prepare_commit(struct ldb_module *module)
 {
        int ret;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        pid_t pid = getpid();
 
        if (ldb_kv->pid != pid) {
-               ldb_asprintf_errstring(
-                       ldb_module_get_ctx(module),
-                       __location__": Reusing ldb opend by pid %d in "
-                       "process %d\n",
-                       ldb_kv->pid,
-                       pid);
+               ldb_asprintf_errstring(ldb_module_get_ctx(module),
+                                      __location__
+                                      ": Reusing ldb opend by pid %d in "
+                                      "process %d\n",
+                                      ldb_kv->pid,
+                                      pid);
                return LDB_ERR_PROTOCOL_ERROR;
        }
 
@@ -1646,7 +1663,8 @@ static int ldb_kv_end_trans(struct ldb_module *module)
 {
        int ret;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
 
        if (!ldb_kv->prepared_commit) {
                ret = ldb_kv_prepare_commit(module);
@@ -1659,10 +1677,11 @@ static int ldb_kv_end_trans(struct ldb_module *module)
 
        if (ldb_kv->kv_ops->finish_write(ldb_kv) != 0) {
                ret = ldb_kv->kv_ops->error(ldb_kv);
-               ldb_asprintf_errstring(ldb_module_get_ctx(module),
-                                      "Failure during tdb_transaction_commit(): %s -> %s",
-                                      ldb_kv->kv_ops->errorstr(ldb_kv),
-                                      ldb_strerror(ret));
+               ldb_asprintf_errstring(
+                   ldb_module_get_ctx(module),
+                   "Failure during tdb_transaction_commit(): %s -> %s",
+                   ldb_kv->kv_ops->errorstr(ldb_kv),
+                   ldb_strerror(ret));
                return ret;
        }
 
@@ -1672,7 +1691,8 @@ static int ldb_kv_end_trans(struct ldb_module *module)
 static int ldb_kv_del_trans(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
 
        if (ldb_kv_index_transaction_cancel(module) != 0) {
                ldb_kv->kv_ops->abort_write(ldb_kv);
@@ -1693,7 +1713,8 @@ static int ldb_kv_sequence_number(struct ldb_kv_context *ctx,
        struct ldb_module *module = ctx->module;
        struct ldb_request *req = ctx->req;
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        TALLOC_CTX *tmp_ctx = NULL;
        struct ldb_seqnum_request *seq;
        struct ldb_seqnum_result *res;
@@ -1903,10 +1924,7 @@ static int ltdb_traverse_fn(struct ldb_kv_private *ldb_kv,
                            void *ctx)
 {
        struct kv_ctx kv_ctx = {
-               .kv_traverse_fn = fn,
-               .ctx = ctx,
-               .ldb_kv = ldb_kv
-       };
+           .kv_traverse_fn = fn, .ctx = ctx, .ldb_kv = ldb_kv};
        if (tdb_transaction_active(ldb_kv->tdb)) {
                return tdb_traverse(
                    ldb_kv->tdb, ltdb_traverse_fn_wrapper, &kv_ctx);
@@ -1944,12 +1962,15 @@ static int ltdb_update_in_iterate(struct ldb_kv_private *ldb_kv,
 
        tdb_ret = tdb_delete(ldb_kv->tdb, key);
        if (tdb_ret != 0) {
-               ldb_debug(ldb, LDB_DEBUG_ERROR,
+               ldb_debug(ldb,
+                         LDB_DEBUG_ERROR,
                          "Failed to delete %*.*s "
                          "for rekey as %*.*s: %s",
-                         (int)key.dsize, (int)key.dsize,
+                         (int)key.dsize,
+                         (int)key.dsize,
                          (const char *)key.dptr,
-                         (int)key2.dsize, (int)key2.dsize,
+                         (int)key2.dsize,
+                         (int)key2.dsize,
                          (const char *)key.dptr,
                          tdb_errorstr(ldb_kv->tdb));
                ctx->error = ltdb_err_map(tdb_error(ldb_kv->tdb));
@@ -1957,11 +1978,14 @@ static int ltdb_update_in_iterate(struct ldb_kv_private *ldb_kv,
        }
        tdb_ret = tdb_store(ldb_kv->tdb, key2, data, 0);
        if (tdb_ret != 0) {
-               ldb_debug(ldb, LDB_DEBUG_ERROR,
+               ldb_debug(ldb,
+                         LDB_DEBUG_ERROR,
                          "Failed to rekey %*.*s as %*.*s: %s",
-                         (int)key.dsize, (int)key.dsize,
+                         (int)key.dsize,
+                         (int)key.dsize,
                          (const char *)key.dptr,
-                         (int)key2.dsize, (int)key2.dsize,
+                         (int)key2.dsize,
+                         (int)key2.dsize,
                          (const char *)key.dptr,
                          tdb_errorstr(ldb_kv->tdb));
                ctx->error = ltdb_err_map(tdb_error(ldb_kv->tdb));
@@ -1994,11 +2018,7 @@ static int ltdb_parse_record(struct ldb_kv_private *ldb_kv,
                                           void *private_data),
                             void *ctx)
 {
-       struct kv_ctx kv_ctx = {
-               .parser = parser,
-               .ctx = ctx,
-               .ldb_kv = ldb_kv
-       };
+       struct kv_ctx kv_ctx = {.parser = parser, .ctx = ctx, .ldb_kv = ldb_kv};
        TDB_DATA key = {
                .dptr = ldb_key.data,
                .dsize = ldb_key.length
@@ -2209,14 +2229,16 @@ static int ldb_kv_init_rootdse(struct ldb_module *module)
 static int ldb_kv_lock_read(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        return ldb_kv->kv_ops->lock_read(module);
 }
 
 static int ldb_kv_unlock_read(struct ldb_module *module)
 {
        void *data = ldb_module_get_private(module);
-       struct ldb_kv_private *ldb_kv = talloc_get_type(data, struct ldb_kv_private);
+       struct ldb_kv_private *ldb_kv =
+           talloc_get_type(data, struct ldb_kv_private);
        return ldb_kv->kv_ops->unlock_read(module);
 }
 
@@ -2385,9 +2407,13 @@ int ltdb_connect(struct ldb_context *ldb, const char *url,
 
        errno = 0;
        /* note that we use quite a large default hash size */
-       ldb_kv->tdb = ltdb_wrap_open(ldb_kv, path, 10000,
-                                  tdb_flags, open_flags,
-                                  ldb_get_create_perms(ldb), ldb);
+       ldb_kv->tdb = ltdb_wrap_open(ldb_kv,
+                                    path,
+                                    10000,
+                                    tdb_flags,
+                                    open_flags,
+                                    ldb_get_create_perms(ldb),
+                                    ldb);
        if (!ldb_kv->tdb) {
                ldb_asprintf_errstring(ldb,
                                       "Unable to open tdb '%s': %s", path, strerror(errno));
index 930405d0f63935fddb2728221d8efbda221bd52e..ae9ce1fc6eec7bf360e0323aa59f089af4a2485b 100644 (file)
@@ -6,19 +6,30 @@
 
 struct ldb_kv_private;
 typedef int (*ldb_kv_traverse_fn)(struct ldb_kv_private *ldb_kv,
-                                 struct ldb_val key, struct ldb_val data,
+                                 struct ldb_val key,
+                                 struct ldb_val data,
                                  void *ctx);
 
 struct kv_db_ops {
-       int (*store)(struct ldb_kv_private *ldb_kv, struct ldb_val key, struct ldb_val data, int flags);
+       int (*store)(struct ldb_kv_private *ldb_kv,
+                    struct ldb_val key,
+                    struct ldb_val data,
+                    int flags);
        int (*delete)(struct ldb_kv_private *ldb_kv, struct ldb_val key);
-       int (*iterate)(struct ldb_kv_private *ldb_kv, ldb_kv_traverse_fn fn, void *ctx);
-       int (*update_in_iterate)(struct ldb_kv_private *ldb_kv, struct ldb_val key,
-                                struct ldb_val key2, struct ldb_val data, void *ctx);
-       int (*fetch_and_parse)(struct ldb_kv_private *ldb_kv, struct ldb_val key,
-                               int (*parser)(struct ldb_val key, struct ldb_val data,
-                                             void *private_data),
-                               void *ctx);
+       int (*iterate)(struct ldb_kv_private *ldb_kv,
+                      ldb_kv_traverse_fn fn,
+                      void *ctx);
+       int (*update_in_iterate)(struct ldb_kv_private *ldb_kv,
+                                struct ldb_val key,
+                                struct ldb_val key2,
+                                struct ldb_val data,
+                                void *ctx);
+       int (*fetch_and_parse)(struct ldb_kv_private *ldb_kv,
+                              struct ldb_val key,
+                              int (*parser)(struct ldb_val key,
+                                            struct ldb_val data,
+                                            void *private_data),
+                              void *ctx);
        int (*lock_read)(struct ldb_module *);
        int (*unlock_read)(struct ldb_module *);
        int (*begin_write)(struct ldb_kv_private *);
@@ -26,8 +37,8 @@ struct kv_db_ops {
        int (*abort_write)(struct ldb_kv_private *);
        int (*finish_write)(struct ldb_kv_private *);
        int (*error)(struct ldb_kv_private *ldb_kv);
-       const char * (*errorstr)(struct ldb_kv_private *ldb_kv);
-       const char * (*name)(struct ldb_kv_private *ldb_kv);
+       const char *(*errorstr)(struct ldb_kv_private *ldb_kv);
+       const char *(*name)(struct ldb_kv_private *ldb_kv);
        bool (*has_changed)(struct ldb_kv_private *ldb_kv);
        bool (*transaction_active)(struct ldb_kv_private *ldb_kv);
 };
index 74aaf03fde2074d85d75c7e783684e16fa275f97..36ea3bf45d59bd06920b58a727b96127650e929b 100644 (file)
@@ -390,7 +390,7 @@ static void test_delete(void **state)
        /*
         * Now delete it.
         */
-       ret = ldb_kv->kv_ops->delete(ldb_kv, key);
+       ret = ldb_kv->kv_ops->delete (ldb_kv, key);
        assert_int_equal(ret, 0);
 
        /*
@@ -551,7 +551,7 @@ static void test_transaction_abort_delete(void **state)
        /*
         * Now delete it.
         */
-       ret = ldb_kv->kv_ops->delete(ldb_kv, key);
+       ret = ldb_kv->kv_ops->delete (ldb_kv, key);
        assert_int_equal(ret, 0);
 
        /*
@@ -680,7 +680,7 @@ static void test_delete_outside_transaction(void **state)
        /*
         * Now attempt to delete a record
         */
-       ret = ldb_kv->kv_ops->delete(ldb_kv, key);
+       ret = ldb_kv->kv_ops->delete (ldb_kv, key);
        assert_int_equal(ret, LDB_ERR_PROTOCOL_ERROR);
 
        /*
@@ -701,7 +701,8 @@ static void test_delete_outside_transaction(void **state)
 static int traverse_fn(struct ldb_kv_private *ldb_kv,
                       struct ldb_val key,
                       struct ldb_val data,
-                      void *ctx) {
+                      void *ctx)
+{
 
        int *visits = ctx;
        int i;
@@ -792,7 +793,8 @@ struct update_context {
 static int update_fn(struct ldb_kv_private *ldb_kv,
                     struct ldb_val key,
                     struct ldb_val data,
-                    void *ctx) {
+                    void *ctx)
+{
 
        struct ldb_val new_key;
        struct ldb_module *module = NULL;
@@ -815,11 +817,8 @@ static int update_fn(struct ldb_kv_private *ldb_kv,
                new_key.length  = key.length;
                new_key.data[0] = 'K';
 
-               ret = ldb_kv->kv_ops->update_in_iterate(ldb_kv,
-                                                     key,
-                                                     new_key,
-                                                     data,
-                                                     &module);
+               ret = ldb_kv->kv_ops->update_in_iterate(
+                   ldb_kv, key, new_key, data, &module);
        }
        TALLOC_FREE(tmp_ctx);
        return ret;
@@ -1484,7 +1483,7 @@ static void test_delete_transaction_isolation(void **state)
        key.data = (uint8_t *)talloc_strdup(tmp_ctx, KEY2);
        key.length = strlen(KEY2) + 1;
 
-       ret = ldb_kv->kv_ops->delete(ldb_kv, key);
+       ret = ldb_kv->kv_ops->delete (ldb_kv, key);
        assert_int_equal(ret, 0);
        /*
         * Signal the child process