ports/154109: [PATCH] devel/jansson: Fix compiler warnings when using library header files
darth at vader.dk
darth at vader.dk
Tue Jan 18 12:10:17 UTC 2011
>Number: 154109
>Category: ports
>Synopsis: [PATCH] devel/jansson: Fix compiler warnings when using library header files
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Jan 18 12:10:15 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Chris Larsen
>Release: FreeBSD 8.1-RELEASE i386
>Organization:
>Environment:
System: FreeBSD vader.dj.s 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Mon Jul 19 02:55:53 UTC 2010
>Description:
Fix compiler warnings when including the libraries header file(s), 'index' has
been used as variable name and thus generates a shadowed global declaration
warning with 'gcc' flag -Wshadow.
Patch does the following;
Renamed variable: index -> my_index
Added file(s):
- files/patch-fix_index_variable
Port maintainer (vanilla at FreeBSD.org) is cc'd.
Generated with FreeBSD Port Tools 0.99
>How-To-Repeat:
make WARNS >= 4 (FreeBSD 8.1) and including jansson.h in source
>Fix:
--- jansson-1.3_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/devel/jansson/Makefile /home/vader/ports/devel/jansson/Makefile
--- /usr/ports/devel/jansson/Makefile 2010-07-01 13:30:49.000000000 +0000
+++ /home/vader/ports/devel/jansson/Makefile 2011-01-18 10:36:58.000000000 +0000
@@ -7,6 +7,7 @@
PORTNAME= jansson
PORTVERSION= 1.3
+PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= http://www.digip.org/jansson/releases/
diff -ruN --exclude=CVS /usr/ports/devel/jansson/files/patch-fix_index_variable /home/vader/ports/devel/jansson/files/patch-fix_index_variable
--- /usr/ports/devel/jansson/files/patch-fix_index_variable 1970-01-01 00:00:00.000000000 +0000
+++ /home/vader/ports/devel/jansson/files/patch-fix_index_variable 2011-01-18 10:18:56.000000000 +0000
@@ -0,0 +1,254 @@
+diff -ur src/hashtable.c src/hashtable.c
+--- src/hashtable.c 2010-06-12 19:43:18.000000000 +0000
++++ src/hashtable.c 2011-01-18 10:14:31.000000000 +0000
+@@ -104,10 +104,10 @@
+ {
+ pair_t *pair;
+ bucket_t *bucket;
+- unsigned int index;
++ unsigned int my_index;
+
+- index = hash % num_buckets(hashtable);
+- bucket = &hashtable->buckets[index];
++ my_index = hash % num_buckets(hashtable);
++ bucket = &hashtable->buckets[my_index];
+
+ pair = hashtable_find_pair(hashtable, bucket, key, hash);
+ if(!pair)
+@@ -156,7 +156,7 @@
+ {
+ list_t *list, *next;
+ pair_t *pair;
+- unsigned int i, index, new_size;
++ unsigned int i, my_index, new_size;
+
+ free(hashtable->buckets);
+
+@@ -179,8 +179,8 @@
+ for(; list != &hashtable->list; list = next) {
+ next = list->next;
+ pair = list_to_pair(list);
+- index = pair->hash % new_size;
+- insert_to_bucket(hashtable, &hashtable->buckets[index], &pair->list);
++ my_index = pair->hash % new_size;
++ insert_to_bucket(hashtable, &hashtable->buckets[my_index], &pair->list);
+ }
+
+ return 0;
+@@ -216,7 +216,7 @@
+ unsigned int i;
+
+ hashtable->size = 0;
+- hashtable->num_buckets = 0; /* index to primes[] */
++ hashtable->num_buckets = 0; /* my_index to primes[] */
+ hashtable->buckets = malloc(num_buckets(hashtable) * sizeof(bucket_t));
+ if(!hashtable->buckets)
+ return -1;
+@@ -247,7 +247,7 @@
+ {
+ pair_t *pair;
+ bucket_t *bucket;
+- unsigned int hash, index;
++ unsigned int hash, my_index;
+
+ /* rehash if the load ratio exceeds 1 */
+ if(hashtable->size >= num_buckets(hashtable))
+@@ -255,8 +255,8 @@
+ return -1;
+
+ hash = hashtable->hash_key(key);
+- index = hash % num_buckets(hashtable);
+- bucket = &hashtable->buckets[index];
++ my_index = hash % num_buckets(hashtable);
++ bucket = &hashtable->buckets[my_index];
+ pair = hashtable_find_pair(hashtable, bucket, key, hash);
+
+ if(pair)
+diff -ur src/jansson.h src/jansson.h
+--- src/jansson.h 2010-06-13 17:39:35.000000000 +0000
++++ src/jansson.h 2011-01-18 10:14:47.000000000 +0000
+@@ -113,18 +113,18 @@
+ }
+
+ unsigned int json_array_size(const json_t *array);
+-json_t *json_array_get(const json_t *array, unsigned int index);
+-int json_array_set_new(json_t *array, unsigned int index, json_t *value);
++json_t *json_array_get(const json_t *array, unsigned int my_index);
++int json_array_set_new(json_t *array, unsigned int my_index, json_t *value);
+ int json_array_append_new(json_t *array, json_t *value);
+-int json_array_insert_new(json_t *array, unsigned int index, json_t *value);
+-int json_array_remove(json_t *array, unsigned int index);
++int json_array_insert_new(json_t *array, unsigned int my_index, json_t *value);
++int json_array_remove(json_t *array, unsigned int my_index);
+ int json_array_clear(json_t *array);
+ int json_array_extend(json_t *array, json_t *other);
+
+ static JSON_INLINE
+-int json_array_set(json_t *array, unsigned int index, json_t *value)
++int json_array_set(json_t *array, unsigned int my_index, json_t *value)
+ {
+- return json_array_set_new(array, index, json_incref(value));
++ return json_array_set_new(array, my_index, json_incref(value));
+ }
+
+ static JSON_INLINE
+@@ -134,9 +134,9 @@
+ }
+
+ static JSON_INLINE
+-int json_array_insert(json_t *array, unsigned int index, json_t *value)
++int json_array_insert(json_t *array, unsigned int my_index, json_t *value)
+ {
+- return json_array_insert_new(array, index, json_incref(value));
++ return json_array_insert_new(array, my_index, json_incref(value));
+ }
+
+ const char *json_string_value(const json_t *string);
+diff -ur src/jansson.h.in src/jansson.h.in
+--- src/jansson.h.in 2010-06-12 19:43:18.000000000 +0000
++++ src/jansson.h.in 2011-01-18 10:15:22.000000000 +0000
+@@ -113,18 +113,18 @@
+ }
+
+ unsigned int json_array_size(const json_t *array);
+-json_t *json_array_get(const json_t *array, unsigned int index);
+-int json_array_set_new(json_t *array, unsigned int index, json_t *value);
++json_t *json_array_get(const json_t *array, unsigned int my_index);
++int json_array_set_new(json_t *array, unsigned int my_index, json_t *value);
+ int json_array_append_new(json_t *array, json_t *value);
+-int json_array_insert_new(json_t *array, unsigned int index, json_t *value);
+-int json_array_remove(json_t *array, unsigned int index);
++int json_array_insert_new(json_t *array, unsigned int my_index, json_t *value);
++int json_array_remove(json_t *array, unsigned int my_index);
+ int json_array_clear(json_t *array);
+ int json_array_extend(json_t *array, json_t *other);
+
+ static JSON_INLINE
+-int json_array_set(json_t *array, unsigned int index, json_t *value)
++int json_array_set(json_t *array, unsigned int my_index, json_t *value)
+ {
+- return json_array_set_new(array, index, json_incref(value));
++ return json_array_set_new(array, my_index, json_incref(value));
+ }
+
+ static JSON_INLINE
+@@ -134,9 +134,9 @@
+ }
+
+ static JSON_INLINE
+-int json_array_insert(json_t *array, unsigned int index, json_t *value)
++int json_array_insert(json_t *array, unsigned int my_index, json_t *value)
+ {
+- return json_array_insert_new(array, index, json_incref(value));
++ return json_array_insert_new(array, my_index, json_incref(value));
+ }
+
+ const char *json_string_value(const json_t *string);
+diff -ur src/value.c src/value.c
+--- src/value.c 2010-06-12 19:43:18.000000000 +0000
++++ src/value.c 2011-01-18 10:15:10.000000000 +0000
+@@ -388,20 +388,20 @@
+ return json_to_array(json)->entries;
+ }
+
+-json_t *json_array_get(const json_t *json, unsigned int index)
++json_t *json_array_get(const json_t *json, unsigned int my_index)
+ {
+ json_array_t *array;
+ if(!json_is_array(json))
+ return NULL;
+ array = json_to_array(json);
+
+- if(index >= array->entries)
++ if(my_index >= array->entries)
+ return NULL;
+
+- return array->table[index];
++ return array->table[my_index];
+ }
+
+-int json_array_set_new(json_t *json, unsigned int index, json_t *value)
++int json_array_set_new(json_t *json, unsigned int my_index, json_t *value)
+ {
+ json_array_t *array;
+
+@@ -415,14 +415,14 @@
+ }
+ array = json_to_array(json);
+
+- if(index >= array->entries)
++ if(my_index >= array->entries)
+ {
+ json_decref(value);
+ return -1;
+ }
+
+- json_decref(array->table[index]);
+- array->table[index] = value;
++ json_decref(array->table[my_index]);
++ array->table[my_index] = value;
+
+ return 0;
+ }
+@@ -494,7 +494,7 @@
+ return 0;
+ }
+
+-int json_array_insert_new(json_t *json, unsigned int index, json_t *value)
++int json_array_insert_new(json_t *json, unsigned int my_index, json_t *value)
+ {
+ json_array_t *array;
+ json_t **old_table;
+@@ -508,7 +508,7 @@
+ }
+ array = json_to_array(json);
+
+- if(index > array->entries) {
++ if(my_index > array->entries) {
+ json_decref(value);
+ return -1;
+ }
+@@ -520,21 +520,21 @@
+ }
+
+ if(old_table != array->table) {
+- array_copy(array->table, 0, old_table, 0, index);
+- array_copy(array->table, index + 1, old_table, index,
+- array->entries - index);
++ array_copy(array->table, 0, old_table, 0, my_index);
++ array_copy(array->table, my_index + 1, old_table, my_index,
++ array->entries - my_index);
+ free(old_table);
+ }
+ else
+- array_move(array, index + 1, index, array->entries - index);
++ array_move(array, my_index + 1, my_index, array->entries - my_index);
+
+- array->table[index] = value;
++ array->table[my_index] = value;
+ array->entries++;
+
+ return 0;
+ }
+
+-int json_array_remove(json_t *json, unsigned int index)
++int json_array_remove(json_t *json, unsigned int my_index)
+ {
+ json_array_t *array;
+
+@@ -542,12 +542,12 @@
+ return -1;
+ array = json_to_array(json);
+
+- if(index >= array->entries)
++ if(my_index >= array->entries)
+ return -1;
+
+- json_decref(array->table[index]);
++ json_decref(array->table[my_index]);
+
+- array_move(array, index, index + 1, array->entries - index);
++ array_move(array, my_index, my_index + 1, array->entries - my_index);
+ array->entries--;
+
+ return 0;
--- jansson-1.3_1.patch ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list