summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/access.c2
-rw-r--r--lib/conf-lex.l8
-rw-r--r--lib/conf-parse.y14
-rw-r--r--lib/general.c34
-rw-r--r--lib/general.h8
-rw-r--r--lib/proc.c4
6 files changed, 38 insertions, 32 deletions
diff --git a/lib/access.c b/lib/access.c
index 566bb384..11038c56 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -449,7 +449,7 @@ int sensors_do_this_chip_sets(sensors_chip_name name)
break;
if (j != feature_count)
continue;
- sensors_add_array_el(&feature_nr,(void **)&feature_list,&feature_count,
+ sensors_add_array_el(&feature_nr,&feature_list,&feature_count,
&feature_max, sizeof(int));
res = sensors_eval_expr(name,chip->sets[i].value,0,&value);
diff --git a/lib/conf-lex.l b/lib/conf-lex.l
index f32451a1..adead65f 100644
--- a/lib/conf-lex.l
+++ b/lib/conf-lex.l
@@ -32,15 +32,15 @@ static char *buffer;
char sensors_lex_error[100];
-#define buffer_malloc() sensors_malloc_array((void **) &buffer,&buffer_count,\
+#define buffer_malloc() sensors_malloc_array(&buffer,&buffer_count,\
&buffer_max,1)
-#define buffer_free() sensors_free_array((void **) &buffer,&buffer_count,\
+#define buffer_free() sensors_free_array(&buffer,&buffer_count,\
&buffer_max)
-#define buffer_add_char(c) sensors_add_array_el(c,(void **) &buffer,\
+#define buffer_add_char(c) sensors_add_array_el(c,&buffer,\
&buffer_count,\
&buffer_max,1)
#define buffer_add_string(s) sensors_add_array_els(s,strlen(s),\
- (void **) &buffer, \
+ &buffer, \
&buffer_count,&buffer_max,1)
%}
diff --git a/lib/conf-parse.y b/lib/conf-parse.y
index 0e35e6d1..ee22e7af 100644
--- a/lib/conf-parse.y
+++ b/lib/conf-parse.y
@@ -41,38 +41,38 @@ static sensors_expr *malloc_expr(void);
static sensors_chip *current_chip = NULL;
#define bus_add_el(el) sensors_add_array_el(el,\
- (void **) &sensors_config_busses,\
+ &sensors_config_busses,\
&sensors_config_busses_count,\
&sensors_config_busses_max,\
sizeof(sensors_bus))
#define label_add_el(el) sensors_add_array_el(el,\
- (void **) &current_chip->labels,\
+ &current_chip->labels,\
&current_chip->labels_count,\
&current_chip->labels_max,\
sizeof(sensors_label));
#define set_add_el(el) sensors_add_array_el(el,\
- (void **) &current_chip->sets,\
+ &current_chip->sets,\
&current_chip->sets_count,\
&current_chip->sets_max,\
sizeof(sensors_set));
#define compute_add_el(el) sensors_add_array_el(el,\
- (void **) &current_chip->computes,\
+ &current_chip->computes,\
&current_chip->computes_count,\
&current_chip->computes_max,\
sizeof(sensors_compute));
#define ignore_add_el(el) sensors_add_array_el(el,\
- (void **) &current_chip->ignores,\
+ &current_chip->ignores,\
&current_chip->ignores_count,\
&current_chip->ignores_max,\
sizeof(sensors_ignore));
#define chip_add_el(el) sensors_add_array_el(el,\
- (void **) &sensors_config_chips,\
+ &sensors_config_chips,\
&sensors_config_chips_count,\
&sensors_config_chips_max,\
sizeof(sensors_chip));
#define fits_add_el(el,list) sensors_add_array_el(el,\
- (void **) &(list).fits,\
+ &(list).fits,\
&(list).fits_count,\
&(list).fits_max, \
sizeof(sensors_chip_name));
diff --git a/lib/general.c b/lib/general.c
index bc15695a..9374b58c 100644
--- a/lib/general.c
+++ b/lib/general.c
@@ -27,51 +27,57 @@
#define A_BUNCH 16
-void sensors_malloc_array(void **list, int *num_el, int *max_el, int el_size)
+void sensors_malloc_array(void *list, int *num_el, int *max_el, int el_size)
{
- *list = malloc(el_size*A_BUNCH);
- if (! *list)
+ void **my_list = (void **)list;
+
+ *my_list = malloc(el_size*A_BUNCH);
+ if (! *my_list)
sensors_fatal_error("sensors_malloc_array","Allocating new elements");
*max_el = A_BUNCH;
*num_el = 0;
}
-void sensors_free_array(void **list, int *num_el, int *max_el)
+void sensors_free_array(void *list, int *num_el, int *max_el)
{
- free(*list);
- *list = NULL;
+ void **my_list = (void **)list;
+
+ free(*my_list);
+ *my_list = NULL;
*num_el = 0;
*max_el = 0;
}
-void sensors_add_array_el(const void *el, void **list, int *num_el,
+void sensors_add_array_el(const void *el, void *list, int *num_el,
int *max_el, int el_size)
{
int new_max_el;
+ void **my_list = (void *)list;
if (*num_el + 1 > *max_el) {
new_max_el = *max_el + A_BUNCH;
- *list = realloc(*list,new_max_el * el_size);
- if (! *list)
+ *my_list = realloc(*my_list,new_max_el * el_size);
+ if (! *my_list)
sensors_fatal_error("sensors_add_array_el","Allocating new elements");
*max_el = new_max_el;
}
- memcpy(((char *) *list) + *num_el * el_size, el, el_size);
+ memcpy(((char *) *my_list) + *num_el * el_size, el, el_size);
(*num_el) ++;
}
-void sensors_add_array_els(const void *els, int nr_els, void **list,
+void sensors_add_array_els(const void *els, int nr_els, void *list,
int *num_el, int *max_el, int el_size)
{
int new_max_el;
+ void **my_list = (void *)list;
if (*num_el + nr_els > *max_el) {
new_max_el = (*max_el + nr_els + A_BUNCH);
new_max_el -= new_max_el % A_BUNCH;
- *list = realloc(*list,new_max_el * el_size);
- if (! *list)
+ *my_list = realloc(*my_list,new_max_el * el_size);
+ if (! *my_list)
sensors_fatal_error("sensors_add_array_els","Allocating new elements");
*max_el = new_max_el;
}
- memcpy(((char *)*list) + *num_el * el_size, els, el_size * nr_els);
+ memcpy(((char *)*my_list) + *num_el * el_size, els, el_size * nr_els);
*num_el += nr_els;
}
diff --git a/lib/general.h b/lib/general.h
index bbe8297d..1bb308ac 100644
--- a/lib/general.h
+++ b/lib/general.h
@@ -25,12 +25,12 @@
made between the current number of elements and the maximum number.
You can only add elements at the end. Primitive, but very useful
for internal use. */
-extern void sensors_malloc_array(void **list, int *num_el, int *max_el,
+extern void sensors_malloc_array(void *list, int *num_el, int *max_el,
int el_size);
-extern void sensors_free_array(void **list, int *num_el, int *max_el);
-extern void sensors_add_array_el(const void *el, void **list, int *num_el,
+extern void sensors_free_array(void *list, int *num_el, int *max_el);
+extern void sensors_add_array_el(const void *el, void *list, int *num_el,
int *max_el, int el_size);
-extern void sensors_add_array_els(const void *els, int nr_els, void **list,
+extern void sensors_add_array_els(const void *els, int nr_els, void *list,
int *num_el, int *max_el, int el_size);
/* Strip a string of all terminating spaces */
diff --git a/lib/proc.c b/lib/proc.c
index 450db5d2..10bb6015 100644
--- a/lib/proc.c
+++ b/lib/proc.c
@@ -60,13 +60,13 @@ int foundsysfs=0;
char sysfsmount[NAME_MAX];
#define add_proc_chips(el) sensors_add_array_el(el,\
- (void **) &sensors_proc_chips,\
+ &sensors_proc_chips,\
&sensors_proc_chips_count,\
&sensors_proc_chips_max,\
sizeof(struct sensors_proc_chips_entry))
#define add_proc_bus(el) sensors_add_array_el(el,\
- (void **) &sensors_proc_bus,\
+ &sensors_proc_bus,\
&sensors_proc_bus_count,\
&sensors_proc_bus_max,\
sizeof(struct sensors_bus))