ldb:"ldb_schema_attribute_by_name_internal" - switch back to 32bit counters
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Mon, 18 Oct 2010 18:19:00 +0000 (20:19 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Mon, 18 Oct 2010 19:01:31 +0000 (19:01 +0000)
Use the signed counter for the binary search but use an unsigned one for
accessing the entry.

Autobuild-User: Matthias Dieter Wallnöfer <mdw@samba.org>
Autobuild-Date: Mon Oct 18 19:01:31 UTC 2010 on sn-devel-104

source4/lib/ldb/common/ldb_attributes.c

index 13f4d327deb50550a5101bd55b9cff43b1b71686..ea6fafd21ab78af6b9e8b9af21df9a06b664a422 100644 (file)
@@ -123,8 +123,8 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal(
        const char *name)
 {
        /* for binary search we need signed variables */
-       long long int i, e, b = 0;
-       int r;
+       int r, i, e, b = 0;
+       unsigned int u_i;
        const struct ldb_schema_attribute *def = &ldb_attribute_default;
 
        /* as handlers are sorted, '*' must be the first if present */
@@ -139,9 +139,10 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal(
        while (b <= e) {
                i = (b + e) / 2;
 
-               r = ldb_attr_cmp(name, ldb->schema.attributes[i].name);
+               u_i = (unsigned int) i;
+               r = ldb_attr_cmp(name, ldb->schema.attributes[u_i].name);
                if (r == 0) {
-                       return &ldb->schema.attributes[i];
+                       return &ldb->schema.attributes[u_i];
                }
                if (r < 0) {
                        e = i - 1;