[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnulib] warnings with gl_anylinked_list
From: |
Bruno Haible |
Subject: |
Re: [bug-gnulib] warnings with gl_anylinked_list |
Date: |
Tue, 10 Oct 2006 14:46:26 +0200 |
User-agent: |
KMail/1.9.1 |
Eric Blake wrote:
> In file included from gl_linkedhash_list.c:89:
> gl_anylinked_list2.h: In function `gl_linked_indexof_from_to':
> gl_anylinked_list2.h:431: warning: declaration of 'index' shadows a previous
> local
> gl_anylinked_list2.h:388: warning: shadowed declaration is here
> gl_anylinked_list2.h:458: warning: declaration of 'index' shadows a previous
> local
> gl_anylinked_list2.h:388: warning: shadowed declaration is here
I see...
> OK to install the following to silence -Wshadow?
No. 'index1' is not a good variable name. I'm installing this instead.
Thanks for the report. It was quite a luck that the references to 'index'
always referred to the intended variable.
2006-10-10 Bruno Haible <address@hidden>
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.
diff -u -r1.1 gl_anyhash_list2.h
--- lib/gl_anyhash_list2.h 17 Jul 2006 11:27:18 -0000 1.1
+++ lib/gl_anyhash_list2.h 10 Oct 2006 12:38:15 -0000
@@ -113,9 +113,9 @@
{
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 -u -r1.5 gl_anylinked_list2.h
--- lib/gl_anylinked_list2.h 6 Oct 2006 12:06:07 -0000 1.5
+++ lib/gl_anylinked_list2.h 10 Oct 2006 12:38:15 -0000
@@ -229,7 +229,7 @@
(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_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_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 @@
(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 @@
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 @@
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 -u -r1.2 gl_anytreehash_list1.h
--- lib/gl_anytreehash_list1.h 5 Oct 2006 12:45:16 -0000 1.2
+++ lib/gl_anytreehash_list1.h 10 Oct 2006 12:38:15 -0000
@@ -109,7 +109,7 @@
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 @@
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 @@
}
}
/* 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 @@
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 @@
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 @@
/* 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 -u -r1.2 gl_anytreehash_list2.h
--- lib/gl_anytreehash_list2.h 5 Oct 2006 12:45:16 -0000 1.2
+++ lib/gl_anytreehash_list2.h 10 Oct 2006 12:38:15 -0000
@@ -31,13 +31,13 @@
(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 @@
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 -u -r1.6 gl_linkedhash_list.c
--- lib/gl_linkedhash_list.c 6 Oct 2006 12:06:07 -0000 1.6
+++ lib/gl_linkedhash_list.c 10 Oct 2006 12:38:15 -0000
@@ -58,20 +58,20 @@
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)
{