From 5a54b204c3d2b6c9282cdd459a3d1030fde48926 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Matthias=20Dieter=20Walln=C3=B6fer?= Date: Fri, 6 Nov 2009 20:14:41 +0100 Subject: [PATCH] s4:schema - Change also here counters to "unsigned" where needed Counters which are used in the way "for (i = 0; array[i] != NULL; i++)" I modified to "unsigned" since for sure we don't want to have negative array indexes there. --- source4/dsdb/schema/schema_convert_to_ol.c | 12 ++++++------ source4/dsdb/schema/schema_description.c | 4 ++-- source4/dsdb/schema/schema_inferiors.c | 12 ++++++------ source4/dsdb/schema/schema_init.c | 9 +++++---- source4/dsdb/schema/schema_prefixmap.c | 2 +- source4/dsdb/schema/schema_query.c | 12 ++++++------ source4/dsdb/schema/schema_set.c | 2 +- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/source4/dsdb/schema/schema_convert_to_ol.c b/source4/dsdb/schema/schema_convert_to_ol.c index f858dc35e90..ff2595cb725 100644 --- a/source4/dsdb/schema/schema_convert_to_ol.c +++ b/source4/dsdb/schema/schema_convert_to_ol.c @@ -62,8 +62,8 @@ static char *print_schema_recursive(char *append_to_string, struct dsdb_schema * .num_values = 1, .values = &objectclass_name_as_ldb_val }; - int j; - int attr_idx; + unsigned int j; + unsigned int attr_idx; if (!mem_ctx) { DEBUG(0, ("Failed to create new talloc context\n")); @@ -183,11 +183,11 @@ char *dsdb_convert_schema_to_openldap(struct ldb_context *ldb, char *target_str, char *line; char *out; const char **attrs_skip = NULL; - int num_skip = 0; + unsigned int num_skip = 0; struct oid_map *oid_map = NULL; - int num_oid_maps = 0; + unsigned int num_oid_maps = 0; struct attr_map *attr_map = NULL; - int num_attr_maps = 0; + unsigned int num_attr_maps = 0; struct dsdb_attribute *attribute; struct dsdb_schema *schema; enum dsdb_schema_convert_target target; @@ -284,7 +284,7 @@ char *dsdb_convert_schema_to_openldap(struct ldb_context *ldb, char *target_str, bool single_value = attribute->isSingleValued; char *schema_entry = NULL; - int j; + unsigned int j; /* We have been asked to skip some attributes/objectClasses */ if (attrs_skip && str_list_check_ci(attrs_skip, name)) { diff --git a/source4/dsdb/schema/schema_description.c b/source4/dsdb/schema/schema_description.c index 0ff8a72bcd1..2014890c949 100644 --- a/source4/dsdb/schema/schema_description.c +++ b/source4/dsdb/schema/schema_description.c @@ -177,7 +177,7 @@ char *schema_attribute_to_extendedInfo(TALLOC_CTX *mem_ctx, const struct dsdb_at #define APPEND_ATTRS(attributes) \ do { \ - int k; \ + unsigned int k; \ for (k=0; attributes && attributes[k]; k++) { \ const char *attr_name = attributes[k]; \ \ @@ -342,7 +342,7 @@ char *schema_class_to_description(TALLOC_CTX *mem_ctx, const struct dsdb_class * char *schema_class_to_dITContentRule(TALLOC_CTX *mem_ctx, const struct dsdb_class *sclass, const struct dsdb_schema *schema) { - int i; + unsigned int i; char *schema_description; const char **aux_class_list = NULL; const char **attrs; diff --git a/source4/dsdb/schema/schema_inferiors.c b/source4/dsdb/schema/schema_inferiors.c index d6fc1cfe5ad..b3f5f31dade 100644 --- a/source4/dsdb/schema/schema_inferiors.c +++ b/source4/dsdb/schema/schema_inferiors.c @@ -79,7 +79,7 @@ static const char **schema_subclasses(const struct dsdb_schema *schema, const char **oclist) { const char **list = const_str_list(str_list_make_empty(mem_ctx)); - int i; + unsigned int i; for (i=0; oclist && oclist[i]; i++) { const struct dsdb_class *schema_class = dsdb_class_by_lDAPDisplayName(schema, oclist[i]); @@ -102,7 +102,7 @@ static const char **schema_posssuperiors(const struct dsdb_schema *schema, if (schema_class->posssuperiors == NULL) { const char **list2 = const_str_list(str_list_make_empty(schema_class)); const char **list3; - int i; + unsigned int i; list2 = str_list_append_const(list2, schema_class->systemPossSuperiors); list2 = str_list_append_const(list2, schema_class->possSuperiors); @@ -128,7 +128,7 @@ static const char **schema_subclasses_recurse(const struct dsdb_schema *schema, struct dsdb_class *schema_class) { const char **list = str_list_copy_const(schema_class, schema_class->subclasses_direct); - int i; + unsigned int i; for (i=0;list && list[i]; i++) { const struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]); if (schema_class != schema_class2) { @@ -146,7 +146,7 @@ void schema_subclasses_order_recurse(const struct dsdb_schema *schema, const int order) { const char **list = schema_class->subclasses_direct; - int i; + unsigned int i; schema_class->subClass_order = order; for (i=0;list && list[i]; i++) { const struct dsdb_class *schema_class2 = dsdb_class_by_lDAPDisplayName(schema, list[i]); @@ -262,7 +262,7 @@ static void schema_fill_from_class_list(const struct dsdb_schema *schema, const uint32_t *ids) { if (*s == NULL && ids != NULL) { - int i; + unsigned int i; for (i=0;ids[i];i++) ; *s = talloc_array(c, const char *, i+1); for (i=0;ids[i];i++) { @@ -287,7 +287,7 @@ static void schema_fill_from_attribute_list(const struct dsdb_schema *schema, const uint32_t *ids) { if (*s == NULL && ids != NULL) { - int i; + unsigned int i; for (i=0;ids[i];i++) ; *s = talloc_array(c, const char *, i+1); for (i=0;ids[i];i++) { diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c index c369d57fa9e..949c1ea0693 100644 --- a/source4/dsdb/schema/schema_init.c +++ b/source4/dsdb/schema/schema_init.c @@ -379,7 +379,7 @@ WERROR dsdb_read_prefixes_from_ldb(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, static bool dsdb_schema_unique_attribute(const char *attr) { const char *attrs[] = { "objectGUID", "objectSID" , NULL }; - int i; + unsigned int i; for (i=0;attrs[i];i++) { if (strcasecmp(attr, attrs[i]) == 0) { return true; @@ -713,7 +713,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, char **error_string) { WERROR status; - uint32_t i; + unsigned int i; const struct ldb_val *prefix_val; const struct ldb_val *info_val; struct ldb_val info_val_default; @@ -845,7 +845,8 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb uint32_t *idx) { WERROR status; - uint32_t i, attid; + unsigned int i; + uint32_t attid; const char *oid = NULL; for(i=0; i < ARRAY_SIZE(name_mappings); i++) { @@ -904,7 +905,7 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb } while (0) #define GET_UINT32_LIST_DS(s, r, attr, mem_ctx, p, elem) do { \ - int list_counter; \ + unsigned int list_counter; \ struct drsuapi_DsReplicaAttribute *_a; \ _a = dsdb_find_object_attr_name(s, r, attr, NULL); \ (p)->elem = _a ? talloc_array(mem_ctx, uint32_t, _a->value_ctr.num_values + 1) : NULL; \ diff --git a/source4/dsdb/schema/schema_prefixmap.c b/source4/dsdb/schema/schema_prefixmap.c index 89d33779e4b..0ed078fa32f 100644 --- a/source4/dsdb/schema/schema_prefixmap.c +++ b/source4/dsdb/schema/schema_prefixmap.c @@ -316,7 +316,7 @@ WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char WERROR dsdb_schema_pfm_oid_from_attid(struct dsdb_schema_prefixmap *pfm, uint32_t attid, TALLOC_CTX *mem_ctx, const char **_oid) { - int i; + uint32_t i; uint32_t hi_word, lo_word; DATA_BLOB bin_oid = {NULL, 0}; struct dsdb_schema_prefixmap_oid *pfm_entry; diff --git a/source4/dsdb/schema/schema_query.c b/source4/dsdb/schema/schema_query.c index ff54488251f..4ff84185f8d 100644 --- a/source4/dsdb/schema/schema_query.c +++ b/source4/dsdb/schema/schema_query.c @@ -219,7 +219,7 @@ WERROR dsdb_linked_attribute_lDAPDisplayName_list(const struct dsdb_schema *sche { const char **attr_list = NULL; struct dsdb_attribute *cur; - int i = 0; + unsigned int i = 0; for (cur = schema->attributes; cur; cur = cur->next) { if (cur->linkID == 0) continue; @@ -239,7 +239,7 @@ const char **merge_attr_list(TALLOC_CTX *mem_ctx, const char **attrs, const char * const*new_attrs) { const char **ret_attrs; - int i; + unsigned int i; size_t new_len, orig_len = str_list_length(attrs); if (!new_attrs) { return attrs; @@ -339,7 +339,7 @@ static const char **dsdb_full_attribute_list_internal(TALLOC_CTX *mem_ctx, const char **class_list, enum dsdb_attr_list_query query) { - int i; + unsigned int i; const char **attr_list = NULL; for (i=0; class_list && class_list[i]; i++) { @@ -366,7 +366,7 @@ static const char **dsdb_full_attribute_list_internal_el(TALLOC_CTX *mem_ctx, const struct ldb_message_element *el, enum dsdb_attr_list_query query) { - int i; + unsigned int i; const char **attr_list = NULL; for (i=0; i < el->num_values; i++) { @@ -391,10 +391,10 @@ static const char **dedup_attr_list(const char **attr_list) size_t new_len = str_list_length(attr_list); /* Remove duplicates */ if (new_len > 1) { - int i; + size_t i; TYPESAFE_QSORT(attr_list, new_len, qsort_string); - for (i=1 ; i < new_len; i++) { + for (i=1; i < new_len; i++) { const char **val1 = &attr_list[i-1]; const char **val2 = &attr_list[i]; if (ldb_attr_cmp(*val1, *val2) == 0) { diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c index 3dace043042..305a0d94f32 100644 --- a/source4/dsdb/schema/schema_set.c +++ b/source4/dsdb/schema/schema_set.c @@ -229,7 +229,7 @@ static int dsdb_setup_sorted_accessors(struct ldb_context *ldb, { struct dsdb_class *cur; struct dsdb_attribute *a; - uint32_t i; + unsigned int i; talloc_free(schema->classes_by_lDAPDisplayName); talloc_free(schema->classes_by_governsID_id); -- 2.11.4.GIT