• D
    Avoid casts between unsigned char * and struct nlmsghdr · e95de74d
    Daniel P. Berrange 提交于
    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: NDaniel P. Berrange <berrange@redhat.com>
    e95de74d
virnetlink.h 3.3 KB