|
Revision 2345, 1.8 kB
(checked in by mmh, 5 years ago)
|
Patch by Philipp Thomas <pth@suse.de>:
Current gcc versions warn when type punning is used, as this breaks the
strict aliasing analysis gcc 3.3 does by default. When checking the causes
for these warnings I discovered that sensors_malloc_array,
sensors_free_array, sensors_add_array_el and sensors_add_array_els in
lib/general.c all take a 'void **' for the list. This is plain wrong as
the C standard only allow 'char *' and 'void *' to alias any other type, so
if these functions should take a generic pointer, it *must* be a 'void *'
that's internally cast to a 'void **'.
The attached patch does this and adapts all places where these functions are
called. Note that when done correctly, no cast what-so-ever in the calling
code is needed.
The patch is against current lm_sensors2 cvs version.
|
- Property svn:eol-style set to
native
- Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
#ifndef LIB_SENSORS_GENERAL |
|---|
| 21 |
#define LIB_SENSORS_GENERAL |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
extern void sensors_malloc_array(void *list, int *num_el, int *max_el, |
|---|
| 29 |
int el_size); |
|---|
| 30 |
extern void sensors_free_array(void *list, int *num_el, int *max_el); |
|---|
| 31 |
extern void sensors_add_array_el(const void *el, void *list, int *num_el, |
|---|
| 32 |
int *max_el, int el_size); |
|---|
| 33 |
extern void sensors_add_array_els(const void *els, int nr_els, void *list, |
|---|
| 34 |
int *num_el, int *max_el, int el_size); |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
extern void sensors_strip_of_spaces(char *name); |
|---|
| 38 |
|
|---|
| 39 |
#endif |
|---|