Eliminate unused-but-set warning from gcc on hashes without datatype
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 3 Mar 2011 15:44:28 +0000 (17:44 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 3 Mar 2011 15:44:28 +0000 (17:44 +0200)
- b_addr is unused if HTDATATYPE isn't defined, more ifdef's yay
- Initialize the local variables on declaration to save one ifdef

lib/rpmhash.C

index 628f2dd..a307bd9 100644 (file)
@@ -108,20 +108,20 @@ void HASHPREFIX(AddEntry)(HASHTYPE ht, HTKEYTYPE key
 #endif
 )
 {
-    unsigned int hash;
-    Bucket b;
-    Bucket * b_addr;
-
-    hash = ht->fn(key) % ht->numBuckets;
-    b = ht->buckets[hash];
-    b_addr = ht->buckets + hash;
+    unsigned int hash = ht->fn(key) % ht->numBuckets;
+    Bucket b = ht->buckets[hash];
+#ifdef HTDATATYPE
+    Bucket * b_addr = ht->buckets + hash;
+#endif
 
     if (b == NULL) {
        ht->bucketCount += 1;
     }
 
     while (b && ht->eq(b->key, key)) {
+#ifdef HTDATATYPE
        b_addr = &(b->next);
+#endif
        b = b->next;
     }