Re: [libvirt] [PATCH 1/3] Fix bridge.c warnings with gcc-4.4

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

 



On Fri, Feb 13, 2009 at 11:54:09AM +0000, Mark McLoughlin wrote:
>  bridge.c: In function 'brSetInetAddr':
>  bridge.c:665: error: dereferencing pointer '({anonymous})' does break strict-aliasing rules
>  bridge.c:665: note: initialized from here
>  bridge.c:666: error: dereferencing pointer '({anonymous})' does break strict-aliasing rules
>  bridge.c:666: note: initialized from here
> 
> Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx>
> ---
>  src/bridge.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/src/bridge.c b/src/bridge.c
> index 990a567..fc11429 100644
> --- a/src/bridge.c
> +++ b/src/bridge.c
> @@ -642,6 +642,10 @@ brSetInetAddr(brControl *ctl,
>                int cmd,
>                const char *addr)
>  {
> +    union {
> +        struct sockaddr sa;
> +        struct sockaddr_in sa_in;
> +    } s;
>      struct ifreq ifr;
>      struct in_addr inaddr;
>      int len, ret;
> @@ -662,8 +666,10 @@ brSetInetAddr(brControl *ctl,
>      else if (ret == 0)
>          return EINVAL;
>  
> -    ((struct sockaddr_in *)&ifr.ifr_data)->sin_family = AF_INET;
> -    ((struct sockaddr_in *)&ifr.ifr_data)->sin_addr   = inaddr;
> +    s.sa_in.sin_family = AF_INET;
> +    s.sa_in.sin_addr   = inaddr;
> +
> +    ifr.ifr_addr = s.sa;
>  
>      if (ioctl(ctl->fd, cmd, &ifr) < 0)
>          return errno;

ACK, though I notice we only cope with IPv4 here ! Have to fix that one
day :-)

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]