From: Bruno Haible Date: Tue, 10 Oct 2006 12:48:57 +0000 (+0000) Subject: Avoid using the variable name 'index' for two completely different things. X-Git-Tag: cvs-readonly~1752 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=935e9f0bda3d20a28516e3e369946fe6fbe60043;p=gnulib.git Avoid using the variable name 'index' for two completely different things. --- diff --git a/ChangeLog b/ChangeLog index 57d8087b2..fcec4908e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-10-10 Bruno Haible + + Fix a gcc -Wshadow warning. + * lib/gl_anyhash_list2.h (hash_resize): Rename local variable 'index' + to 'bucket'. + * lib/gl_anylinked_list2.h (gl_linked_search_from_to, + gl_linked_indexof_from_to): Likewise. + * lib/gl_linkedhash_list.c (add_to_bucket, remove_from_bucket): + Likewise. + * lib/gl_anytreehash_list1.h (add_to_bucket, remove_from_bucket): + Likewise. + * lib/gl_anytreehash_list2.h (gl_tree_search_from_to): Likewise. + Reported by Eric Blake. + 2006-10-09 Paul Eggert * lib/filemode.h [HAVE_DECL_STRMODE]: Include unistd.h too, diff --git a/lib/gl_anyhash_list2.h b/lib/gl_anyhash_list2.h index eb8d6e977..78ee593a8 100644 --- a/lib/gl_anyhash_list2.h +++ b/lib/gl_anyhash_list2.h @@ -113,9 +113,9 @@ hash_resize (gl_list_t list, size_t estimate) { gl_hash_entry_t next = node->hash_next; /* Add the entry to the new table. */ - size_t index = node->hashcode % new_size; - node->hash_next = new_table[index]; - new_table[index] = node; + size_t bucket = node->hashcode % new_size; + node->hash_next = new_table[bucket]; + new_table[bucket] = node; node = next; } diff --git a/lib/gl_anylinked_list2.h b/lib/gl_anylinked_list2.h index bc551edd6..775336754 100644 --- a/lib/gl_anylinked_list2.h +++ b/lib/gl_anylinked_list2.h @@ -229,7 +229,7 @@ gl_linked_search_from_to (gl_list_t list, size_t start_index, size_t end_index, (list->base.hashcode_fn != NULL ? list->base.hashcode_fn (elt) : (size_t)(uintptr_t) elt); - size_t index = hashcode % list->table_size; + size_t bucket = hashcode % list->table_size; gl_listelement_equals_fn equals = list->base.equals_fn; if (!list->base.allow_duplicates) @@ -238,7 +238,7 @@ gl_linked_search_from_to (gl_list_t list, size_t start_index, size_t end_index, gl_list_node_t found = NULL; gl_list_node_t node; - for (node = (gl_list_node_t) list->table[index]; + for (node = (gl_list_node_t) list->table[bucket]; node != NULL; node = (gl_list_node_t) node->h.hash_next) if (node->h.hashcode == hashcode @@ -279,7 +279,7 @@ gl_linked_search_from_to (gl_list_t list, size_t start_index, size_t end_index, gl_list_node_t first_match = NULL; gl_list_node_t node; - for (node = (gl_list_node_t) list->table[index]; + for (node = (gl_list_node_t) list->table[bucket]; node != NULL; node = (gl_list_node_t) node->h.hash_next) if (node->h.hashcode == hashcode @@ -385,7 +385,7 @@ gl_linked_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, (list->base.hashcode_fn != NULL ? list->base.hashcode_fn (elt) : (size_t)(uintptr_t) elt); - size_t index = hashcode % list->table_size; + size_t bucket = hashcode % list->table_size; gl_listelement_equals_fn equals = list->base.equals_fn; gl_list_node_t node; @@ -393,7 +393,7 @@ gl_linked_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, if (!list->base.allow_duplicates) { /* Look for the first match in the hash bucket. */ - for (node = (gl_list_node_t) list->table[index]; + for (node = (gl_list_node_t) list->table[bucket]; node != NULL; node = (gl_list_node_t) node->h.hash_next) if (node->h.hashcode == hashcode @@ -408,7 +408,7 @@ gl_linked_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index, bool multiple_matches = false; gl_list_node_t first_match = NULL; - for (node = (gl_list_node_t) list->table[index]; + for (node = (gl_list_node_t) list->table[bucket]; node != NULL; node = (gl_list_node_t) node->h.hash_next) if (node->h.hashcode == hashcode diff --git a/lib/gl_anytreehash_list1.h b/lib/gl_anytreehash_list1.h index f6e319b49..fac02b6ae 100644 --- a/lib/gl_anytreehash_list1.h +++ b/lib/gl_anytreehash_list1.h @@ -109,7 +109,7 @@ gl_oset_first (gl_oset_t set) static void add_to_bucket (gl_list_t list, gl_list_node_t new_node) { - size_t index = new_node->h.hashcode % list->table_size; + size_t bucket = new_node->h.hashcode % list->table_size; /* If no duplicates are allowed, multiple nodes are not needed. */ if (list->base.allow_duplicates) @@ -119,7 +119,7 @@ add_to_bucket (gl_list_t list, gl_list_node_t new_node) gl_listelement_equals_fn equals = list->base.equals_fn; gl_hash_entry_t *entryp; - for (entryp = &list->table[index]; *entryp != NULL; entryp = &(*entryp)->hash_next) + for (entryp = &list->table[bucket]; *entryp != NULL; entryp = &(*entryp)->hash_next) { gl_hash_entry_t entry = *entryp; @@ -171,8 +171,8 @@ add_to_bucket (gl_list_t list, gl_list_node_t new_node) } } /* If no duplicates are allowed, multiple nodes are not needed. */ - new_node->h.hash_next = list->table[index]; - list->table[index] = &new_node->h; + new_node->h.hash_next = list->table[bucket]; + list->table[bucket] = &new_node->h; } /* Remove a node from the hash table structure. @@ -184,7 +184,7 @@ add_to_bucket (gl_list_t list, gl_list_node_t new_node) static void remove_from_bucket (gl_list_t list, gl_list_node_t old_node) { - size_t index = old_node->h.hashcode % list->table_size; + size_t bucket = old_node->h.hashcode % list->table_size; if (list->base.allow_duplicates) { @@ -193,7 +193,7 @@ remove_from_bucket (gl_list_t list, gl_list_node_t old_node) gl_listelement_equals_fn equals = list->base.equals_fn; gl_hash_entry_t *entryp; - for (entryp = &list->table[index]; ; entryp = &(*entryp)->hash_next) + for (entryp = &list->table[bucket]; ; entryp = &(*entryp)->hash_next) { gl_hash_entry_t entry = *entryp; @@ -239,7 +239,7 @@ remove_from_bucket (gl_list_t list, gl_list_node_t old_node) /* If no duplicates are allowed, multiple nodes are not needed. */ gl_hash_entry_t *entryp; - for (entryp = &list->table[index]; ; entryp = &(*entryp)->hash_next) + for (entryp = &list->table[bucket]; ; entryp = &(*entryp)->hash_next) { if (*entryp == &old_node->h) { diff --git a/lib/gl_anytreehash_list2.h b/lib/gl_anytreehash_list2.h index 1b324e94c..f69f98399 100644 --- a/lib/gl_anytreehash_list2.h +++ b/lib/gl_anytreehash_list2.h @@ -31,13 +31,13 @@ gl_tree_search_from_to (gl_list_t list, size_t start_index, size_t end_index, (list->base.hashcode_fn != NULL ? list->base.hashcode_fn (elt) : (size_t)(uintptr_t) elt); - size_t index = hashcode % list->table_size; + size_t bucket = hashcode % list->table_size; gl_listelement_equals_fn equals = list->base.equals_fn; gl_hash_entry_t entry; if (list->base.allow_duplicates) { - for (entry = list->table[index]; entry != NULL; entry = entry->hash_next) + for (entry = list->table[bucket]; entry != NULL; entry = entry->hash_next) if (entry->hashcode == hashcode) { if (((struct gl_multiple_nodes *) entry)->magic == MULTIPLE_NODES_MAGIC) @@ -102,7 +102,7 @@ gl_tree_search_from_to (gl_list_t list, size_t start_index, size_t end_index, else { /* If no duplicates are allowed, multiple nodes are not needed. */ - for (entry = list->table[index]; entry != NULL; entry = entry->hash_next) + for (entry = list->table[bucket]; entry != NULL; entry = entry->hash_next) if (entry->hashcode == hashcode) { gl_list_node_t node = (struct gl_list_node_impl *) entry; diff --git a/lib/gl_linkedhash_list.c b/lib/gl_linkedhash_list.c index 73c2f448a..89173f51b 100644 --- a/lib/gl_linkedhash_list.c +++ b/lib/gl_linkedhash_list.c @@ -58,20 +58,20 @@ hash_resize_after_add (gl_list_t list) static inline void add_to_bucket (gl_list_t list, gl_list_node_t node) { - size_t index = node->h.hashcode % list->table_size; + size_t bucket = node->h.hashcode % list->table_size; - node->h.hash_next = list->table[index]; - list->table[index] = &node->h; + node->h.hash_next = list->table[bucket]; + list->table[bucket] = &node->h; } /* Remove a node from the hash table structure. */ static inline void remove_from_bucket (gl_list_t list, gl_list_node_t node) { - size_t index = node->h.hashcode % list->table_size; + size_t bucket = node->h.hashcode % list->table_size; gl_hash_entry_t *p; - for (p = &list->table[index]; ; p = &(*p)->hash_next) + for (p = &list->table[bucket]; ; p = &(*p)->hash_next) { if (*p == &node->h) {