Original warnings:

../../../common/dhash/dhash_test.c: In function ‘main’:
../../../common/dhash/dhash_test.c:288: warning: declaration of ‘i’
shadows a previous local
../../../common/dhash/dhash_test.c:115: warning: shadowed declaration is
here
../../../common/dhash/dhash_test.c:312: warning: declaration of ‘i’
shadows a previous local
../../../common/dhash/dhash_test.c:115: warning: shadowed declaration is
here
../../../common/dhash/dhash_test.c:332: warning: declaration of ‘i’
shadows a previous local
../../../common/dhash/dhash_test.c:115: warning: shadowed declaration is
here
../../../common/dhash/dhash_example.c: In function ‘main’:
../../../common/dhash/dhash_example.c:44: warning: passing argument 2 of
‘new_data’ discards qualifiers from pointer target type
../../../common/dhash/dhash_example.c:28: note: expected ‘char *’ but
argument is of type ‘const char *’
../../../common/dhash/dhash_example.c:55: warning: assignment discards
qualifiers from pointer target type
../../../common/dhash/dhash_example.c:76: warning: assignment discards
qualifiers from pointer target type
../../../common/dhash/dhash_example.c:94: warning: declaration of
‘my_data’ shadows a previous local
../../../common/dhash/dhash_example.c:44: warning: shadowed declaration
is here
../../../common/dhash/dhash_example.c:105: warning: assignment discards
qualifiers from pointer target type

-- 
Stephen Gallagher
RHCE 804006346421761

Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
From 60f4231bbb57585b0f75d854c06947170205b6e4 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Thu, 29 Oct 2009 13:41:01 -0400
Subject: [PATCH] Clean up warnings in dhash tests

---
 common/dhash/dhash_example.c |   12 ++++++------
 common/dhash/dhash_test.c    |    6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/common/dhash/dhash_example.c b/common/dhash/dhash_example.c
index af46ca8..b7de623 100644
--- a/common/dhash/dhash_example.c
+++ b/common/dhash/dhash_example.c
@@ -25,7 +25,7 @@ bool visit_callback(hash_entry_t *entry, void *user_data)
     return true;
 }
 
-struct my_data_t *new_data(int foo, char *bar)
+struct my_data_t *new_data(int foo, const char *bar)
 {
     struct my_data_t *my_data = malloc(sizeof(struct my_data_t));
     my_data->foo = foo;
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
 
     /* Enter a key named "My Data" and specify it's value as a pointer to 
my_data */
     key.type = HASH_KEY_STRING;
-    key.str = "My Data";
+    key.str = strdup("My Data");
     value.type = HASH_VALUE_PTR;
     value.ptr = my_data;
 
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
 
     /* Lookup the key named "My Data" */
     key.type = HASH_KEY_STRING;
-    key.str = "My Data";
+    key.str = strdup("My Data");
     if ((error = hash_lookup(table, &key, &value)) != HASH_SUCCESS) {
         fprintf(stderr, "cannot find key \"%s\" (%s)\n", key.str, 
hash_error_string(error));
     }
@@ -91,9 +91,9 @@ int main(int argc, char **argv)
     n_entries = 0;
     iter = new_hash_iter_context(table);
     while ((entry = iter->next(iter)) != NULL) {
-        struct my_data_t *my_data = (struct my_data_t *) entry->value.ptr;
+        struct my_data_t *data = (struct my_data_t *) entry->value.ptr;
 
-        printf("%s = [foo=%d bar=%s]\n", entry->key.str, my_data->foo, 
my_data->bar);
+        printf("%s = [foo=%d bar=%s]\n", entry->key.str, data->foo, data->bar);
         n_entries++;
     }
     free(iter);
@@ -102,7 +102,7 @@ int main(int argc, char **argv)
 
     /* Remove the entry, deletion callback will be invoked */
     key.type = HASH_KEY_STRING;
-    key.str = "My Data";
+    key.str = strdup("My Data");
     if ((error = hash_delete(table, &key)) != HASH_SUCCESS) {
         fprintf(stderr, "cannot delete from table (%s)\n", 
hash_error_string(error));
     }
diff --git a/common/dhash/dhash_test.c b/common/dhash/dhash_test.c
index 8509964..450a1ab 100644
--- a/common/dhash/dhash_test.c
+++ b/common/dhash/dhash_test.c
@@ -285,7 +285,7 @@ int main(int argc, char **argv)
 
     /* Get an array of keys in the table, print them out */
     {
-        unsigned long i, count;
+        unsigned long count;
         hash_key_t *keys;
 
         if (verbose) printf("\nhash_keys:\n");
@@ -309,7 +309,7 @@ int main(int argc, char **argv)
 
     /* Get an array of values in the table, print them out */
     {
-        unsigned long i, count;
+        unsigned long count;
         hash_value_t *values;
 
         if (verbose) printf("\nhash_values:\n");
@@ -329,7 +329,7 @@ int main(int argc, char **argv)
 
     /* Get an array of items in the table, print them out */
     {
-        unsigned long i, count;
+        unsigned long count;
         hash_entry_t *entries;
 
         if (verbose) printf("\nhash_entries:\n");
-- 
1.6.2.5

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to