ports/155154: [PATCH] devel/jansson: Fix compiler warnings when using library header files

darth at vader.dk darth at vader.dk
Tue Mar 1 14:00:24 UTC 2011


>Number:         155154
>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 Mar 01 14:00:20 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:

Essentially the same fix as PR ports/154109 which corrected the same issue
just with devel/jansson version: 1.3

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-2.0_1.patch begins here ---
diff -ruN --exclude=CVS /usr/ports/devel/jansson/Makefile /home/vader/ports/devel/jansson/Makefile
--- /usr/ports/devel/jansson/Makefile	2011-03-01 13:17:42.000000000 +0000
+++ /home/vader/ports/devel/jansson/Makefile	2011-03-01 13:20:39.000000000 +0000
@@ -7,7 +7,7 @@
 
 PORTNAME=	jansson
 PORTVERSION=	2.0
-PORTREVISION=	0
+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-03-01 13:14:09.000000000 +0000
@@ -0,0 +1,207 @@
+diff -u src/hashtable.c src/hashtable.c
+--- src/hashtable.c	2011-02-19 12:57:37.000000000 +0100
++++ src/hashtable.c	2011-03-01 14:00:27.000000000 +0100
+@@ -101,10 +101,10 @@
+ {
+     pair_t *pair;
+     bucket_t *bucket;
+-    size_t index;
++    size_t 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)
+@@ -153,7 +153,7 @@
+ {
+     list_t *list, *next;
+     pair_t *pair;
+-    size_t i, index, new_size;
++    size_t i, my_index, new_size;
+ 
+     jsonp_free(hashtable->buckets);
+ 
+@@ -176,8 +176,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;
+@@ -244,7 +244,7 @@
+ {
+     pair_t *pair;
+     bucket_t *bucket;
+-    size_t hash, index;
++    size_t hash, my_index;
+ 
+     /* rehash if the load ratio exceeds 1 */
+     if(hashtable->size >= num_buckets(hashtable))
+@@ -252,8 +252,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 -u src/jansson.h src/jansson.h
+--- src/jansson.h	2011-02-25 20:09:04.000000000 +0100
++++ src/jansson.h	2011-03-01 14:00:10.000000000 +0100
+@@ -152,18 +152,18 @@
+ }
+ 
+ size_t json_array_size(const json_t *array);
+-json_t *json_array_get(const json_t *array, size_t index);
+-int json_array_set_new(json_t *array, size_t index, json_t *value);
++json_t *json_array_get(const json_t *array, size_t my_index);
++int json_array_set_new(json_t *array, size_t my_index, json_t *value);
+ int json_array_append_new(json_t *array, json_t *value);
+-int json_array_insert_new(json_t *array, size_t index, json_t *value);
+-int json_array_remove(json_t *array, size_t index);
++int json_array_insert_new(json_t *array, size_t my_index, json_t *value);
++int json_array_remove(json_t *array, size_t 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, size_t index, json_t *value)
++int json_array_set(json_t *array, size_t 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
+@@ -173,9 +173,9 @@
+ }
+ 
+ static JSON_INLINE
+-int json_array_insert(json_t *array, size_t index, json_t *value)
++int json_array_insert(json_t *array, size_t 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 -u src/value.c src/value.c
+--- src/value.c	2011-02-19 12:57:37.000000000 +0100
++++ src/value.c	2011-03-01 13:59:49.000000000 +0100
+@@ -390,20 +390,20 @@
+     return json_to_array(json)->entries;
+ }
+ 
+-json_t *json_array_get(const json_t *json, size_t index)
++json_t *json_array_get(const json_t *json, size_t 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, size_t index, json_t *value)
++int json_array_set_new(json_t *json, size_t my_index, json_t *value)
+ {
+     json_array_t *array;
+ 
+@@ -417,14 +417,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;
+ }
+@@ -496,7 +496,7 @@
+     return 0;
+ }
+ 
+-int json_array_insert_new(json_t *json, size_t index, json_t *value)
++int json_array_insert_new(json_t *json, size_t my_index, json_t *value)
+ {
+     json_array_t *array;
+     json_t **old_table;
+@@ -510,7 +510,7 @@
+     }
+     array = json_to_array(json);
+ 
+-    if(index > array->entries) {
++    if(my_index > array->entries) {
+         json_decref(value);
+         return -1;
+     }
+@@ -522,21 +522,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);
+         jsonp_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, size_t index)
++int json_array_remove(json_t *json, size_t my_index)
+ {
+     json_array_t *array;
+ 
+@@ -544,12 +544,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-2.0_1.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list