diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2009-11-06 18:35:17 +0100 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-08 12:52:24 +0100 |
commit | 4e16a285c7c34732ba95fb5ec201e6f11cf88bef (patch) | |
tree | 9fcc4fc18c0c6a36728a511eacd34535bbec8178 /source4/lib/ldb/common/ldb_attributes.c | |
parent | 30ff229a3e32549073424b423302e976c988d563 (diff) | |
download | samba-4e16a285c7c34732ba95fb5ec201e6f11cf88bef.tar.gz samba-4e16a285c7c34732ba95fb5ec201e6f11cf88bef.tar.bz2 samba-4e16a285c7c34732ba95fb5ec201e6f11cf88bef.zip |
LDB:common - Change counters to "unsigned" where appropriate
To count LDB objects use variables of type "unsigned (int)" or "long long int"
on binary or downto searches.
To count characters in strings use "size_t".
To calculate differences between pointers use "ptrdiff_t".
Diffstat (limited to 'source4/lib/ldb/common/ldb_attributes.c')
-rw-r--r-- | source4/lib/ldb/common/ldb_attributes.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index 79c5dd69de..13f4d327de 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -49,7 +49,7 @@ int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb, unsigned flags, const struct ldb_schema_syntax *syntax) { - int i, n; + unsigned int i, n; struct ldb_schema_attribute *a; if (!syntax) { @@ -122,7 +122,9 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal( struct ldb_context *ldb, const char *name) { - int i, e, b = 0, r; + /* for binary search we need signed variables */ + long long int i, e, b = 0; + int r; const struct ldb_schema_attribute *def = &ldb_attribute_default; /* as handlers are sorted, '*' must be the first if present */ @@ -135,7 +137,6 @@ static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal( e = ldb->schema.num_attributes - 1; while (b <= e) { - i = (b + e) / 2; r = ldb_attr_cmp(name, ldb->schema.attributes[i].name); @@ -179,7 +180,7 @@ const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_conte void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name) { const struct ldb_schema_attribute *a; - int i; + ptrdiff_t i; a = ldb_schema_attribute_by_name_internal(ldb, name); if (a == NULL || a->name == NULL) { @@ -232,7 +233,7 @@ int ldb_setup_wellknown_attributes(struct ldb_context *ldb) { "ou", LDB_SYNTAX_DIRECTORY_STRING }, { "objectClass", LDB_SYNTAX_OBJECTCLASS } }; - int i; + unsigned int i; int ret; for (i=0;i<ARRAY_SIZE(wellknown);i++) { @@ -254,7 +255,7 @@ int ldb_dn_extended_add_syntax(struct ldb_context *ldb, unsigned flags, const struct ldb_dn_extended_syntax *syntax) { - int n; + unsigned int n; struct ldb_dn_extended_syntax *a; if (!syntax) { @@ -284,7 +285,7 @@ int ldb_dn_extended_add_syntax(struct ldb_context *ldb, const struct ldb_dn_extended_syntax *ldb_dn_extended_syntax_by_name(struct ldb_context *ldb, const char *name) { - int i; + unsigned int i; for (i=0; i < ldb->schema.num_dn_extended_syntax; i++) { if (ldb_attr_cmp(ldb->schema.dn_extended_syntax[i].name, name) == 0) { return &ldb->schema.dn_extended_syntax[i]; |