From 4e16a285c7c34732ba95fb5ec201e6f11cf88bef Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Fri, 6 Nov 2009 18:35:17 +0100 Subject: 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". --- source4/lib/ldb/common/ldb_attributes.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/common/ldb_attributes.c') diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index 79c5dd69de4..13f4d327deb 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;ischema.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]; -- cgit