Fix for type punning in lm_sensors2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Philipp


-- 
Philipp Thomas <pth at suse.de>
SUSE LINUX AG, Maxfeldstr. 5, D-90409 Nuremberg, Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm_sensors.diff
Type: text/x-patch
Size: 10165 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040305/4221e071/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20040305/4221e071/attachment-0001.bin 


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux