]> git.ipfire.org Git - thirdparty/libvirt.git/commit
Avoid casts between unsigned char * and struct nlmsghdr
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 3 Apr 2013 13:09:19 +0000 (14:09 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 8 Apr 2013 09:03:21 +0000 (10:03 +0100)
commite95de74d4c6eac821b666ae706e8fc002ca688d1
treee19860d164a3421409cf8a0525cb8bcb3d282e80
parentd27efd8e5d15117b19b66fda6ec88c87468d3897
Avoid casts between unsigned char * and struct nlmsghdr

The virNetlinkCommand() method takes an 'unsigned char **'
parameter to be filled with the received netlink message.
The callers then immediately cast this to 'struct nlmsghdr',
triggering (bogus) warnings about increasing alignment
requirements

util/virnetdev.c: In function 'virNetDevLinkDump':
util/virnetdev.c:1300:12: warning: cast increases required alignment of target type [-Wcast-align]
     resp = (struct nlmsghdr *)*recvbuf;
            ^
util/virnetdev.c: In function 'virNetDevSetVfConfig':
util/virnetdev.c:1429:12: warning: cast increases required alignment of target type [-Wcast-align]
     resp = (struct nlmsghdr *)recvbuf;

Since all callers cast to 'struct nlmsghdr' we can avoid
the warning problem entirely by simply changing the
signature of virNetlinkCommand to return a 'struct nlmsghdr **'
instead of 'unsigned char **'. The way we do the cast inside
virNetlinkCommand does not have any alignment issues.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/util/virnetdev.c
src/util/virnetdev.h
src/util/virnetdevmacvlan.c
src/util/virnetdevvportprofile.c
src/util/virnetlink.c
src/util/virnetlink.h