Message ID | 1452701360-31323-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 13/01/16 16:09, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Signed-off-by: Colin Ian King <colin.king@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
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@canonical.com> >> >> Signed-off-by: Colin Ian King <colin.king@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
On 2016-01-14 12:09 AM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Signed-off-by: Colin Ian King <colin.king@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); > Acked-by: Alex Hung <alex.hung@canonical.com>
On 2016年01月14日 00:09, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > Signed-off-by: Colin Ian King <colin.king@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); Acked-by: Ivan Hu <ivan.hu@canonical.com>
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);