ldb:"ldb_dn_canonical" - use an "unsigned int" counter
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 16 Oct 2010 12:47:42 +0000 (14:47 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 16 Oct 2010 12:57:52 +0000 (14:57 +0200)
Convert it to use an "unsigned int" counter which represents the exact length
of the DN components.

source4/lib/ldb/common/ldb_dn.c

index 9bbefddb8e4c00c6a757ff8ca2399ae1eec639a6..2b640687b17f74333c6ef0b447e9d76263d7e8e6 100644 (file)
@@ -1711,7 +1711,7 @@ struct ldb_dn *ldb_dn_get_parent(TALLOC_CTX *mem_ctx, struct ldb_dn *dn)
 
 */
 static char *ldb_dn_canonical(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int ex_format) {
-       long long int i;
+       unsigned int i;
        TALLOC_CTX *tmpctx;
        char *cracked = NULL;
        const char *format = (ex_format ? "\n" : "/" );
@@ -1723,7 +1723,7 @@ static char *ldb_dn_canonical(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int ex_for
        tmpctx = talloc_new(mem_ctx);
 
        /* Walk backwards down the DN, grabbing 'dc' components at first */
-       for (i = dn->comp_num - 1; i >= 0; i--) {
+       for (i = dn->comp_num - 1; i != (unsigned int) -1; i--) {
                if (ldb_attr_cmp(dn->components[i].name, "dc") != 0) {
                        break;
                }
@@ -1742,7 +1742,7 @@ static char *ldb_dn_canonical(TALLOC_CTX *mem_ctx, struct ldb_dn *dn, int ex_for
        }
 
        /* Only domain components?  Finish here */
-       if (i < 0) {
+       if (i == (unsigned int) -1) {
                cracked = talloc_strdup_append_buffer(cracked, format);
                talloc_steal(mem_ctx, cracked);
                goto done;