NACK: [PATCH] lib: fwts_hwinfo: clean up type punning, fixes warning with gcc-6

Colin Ian King colin.king at canonical.com
Fri Jan 15 14:15:53 UTC 2016


On 15/01/16 11:55, Colin Ian King wrote:
> On 13/01/16 16:09, Colin King wrote:
>> From: Colin Ian King <colin.king at canonical.com>
>>
>> Signed-off-by: Colin Ian King <colin.king at canonical.com>
>> ---
>>  src/lib/src/fwts_hwinfo.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/lib/src/fwts_hwinfo.c b/src/lib/src/fwts_hwinfo.c
>> index 6a0a9aa..e8f7c05 100644
>> --- a/src/lib/src/fwts_hwinfo.c
>> +++ b/src/lib/src/fwts_hwinfo.c
>> @@ -381,7 +381,7 @@ static int fwts_hwinfo_net_get(
>>  
>>  	while ((d = readdir(dp)) != NULL) {
>>  		struct ifreq buf;
>> -		struct in_addr in_addr;
>> +		struct sockaddr_in *sockaddr;
>>  		fwts_net_config *net_config;
>>  
>>  		if (d->d_name[0] == '.')
>> @@ -416,8 +416,8 @@ static int fwts_hwinfo_net_get(
>>  				fwts_log_error(fw, "Cannot get address for device %s.", d->d_name);
>>  		}
>>  		/* GCC 4.4 is rather overly pedantic in strict aliasing warnings, this avoids it */
>> -		in_addr = (struct in_addr)((struct sockaddr_in *)&buf.ifr_addr)->sin_addr;
>> -		net_config->addr = strdup(inet_ntoa(in_addr));
>> +		sockaddr = (struct sockaddr_in *)&buf.ifr_addr;
>> +		net_config->addr = strdup(inet_ntoa((struct in_addr)sockaddr->sin_addr));
>>  		if (net_config->addr == NULL) {
>>  			fwts_log_error(fw, "Cannot allocate net config H/W address.");
>>  			fwts_hwinfo_net_free(net_config);
>>
> NACK, this produces warnings on other older compilers
> 
> Colin
> 
Nope, I was being stupid and building my code w/o this patch.  Ignore my
NACK, tested with:

gcc 4.6.3
gcc 4.8.4
gcc 4.9.2
gcc 5.2.1
gcc 6.0.0

So this patch is OK for the current builds and for Xenial+1.  Ignore the
NACK.

Colin






More information about the fwts-devel mailing list