hash: silence spurious clang warning
authorBruno Haible <bruno@clisp.org>
Tue, 31 Aug 2010 06:43:53 +0000 (08:43 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 31 Aug 2010 06:43:53 +0000 (08:43 +0200)
* lib/hash.c (hash_get_next): Remove unnecessary test against NULL.
Reported by Eric Blake.

ChangeLog
lib/hash.c

index a7b5e68..a61bf9f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-30  Bruno Haible  <bruno@clisp.org>
+
+       hash: silence spurious clang warning
+       * lib/hash.c (hash_get_next): Remove unnecessary test against NULL.
+       Reported by Eric Blake.
+
 2010-08-30  Eric Blake  <eblake@redhat.com>
 
        strstr, memmem, strcasestr: avoid leaked shell message
index 15630be..2258652 100644 (file)
@@ -307,9 +307,14 @@ hash_get_next (const Hash_table *table, const void *entry)
     abort ();
 
   /* Find next entry in the same bucket.  */
-  for (cursor = bucket; cursor; cursor = cursor->next)
-    if (cursor->data == entry && cursor->next)
-      return cursor->next->data;
+  cursor = bucket;
+  do
+    {
+      if (cursor->data == entry && cursor->next)
+        return cursor->next->data;
+      cursor = cursor->next;
+    }
+  while (cursor != NULL);
 
   /* Find first entry in any subsequent bucket.  */
   while (++bucket < table->bucket_limit)