SLIRP warning messages displayed while compiling

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

SLIRP warning messages displayed while compiling

Programmingkid
Host: Mac OS 10.12.5
Compiler: Apple LLVM version 8.1.0 (clang-802.0.42)
Command used: ./configure --target-list=ppc-softmmu,i386-softmmu && make -j 4

While compiling I saw these error messages:

slirp/ip6_icmp.c:79:32: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) ||
                               ^~~~~~~~~~
/usr/include/netinet6/in6.h:299:36: note: expanded from macro 'IN6_IS_ADDR_MULTICAST'
#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
                                          ^
slirp/ip6_icmp.c:80:38: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                     ^~~~~~~~~~
/usr/include/netinet6/in6.h:238:42: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
                                                ^
slirp/ip6_icmp.c:80:38: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                     ^~~~~~~~~~
/usr/include/netinet6/in6.h:239:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
                                               ^
slirp/ip6_icmp.c:80:38: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                     ^~~~~~~~~~
/usr/include/netinet6/in6.h:240:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
                                               ^
slirp/ip6_icmp.c:80:38: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                     ^~~~~~~~~~
/usr/include/netinet6/in6.h:241:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
                                               ^
slirp/ip6_icmp.c:275:34: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    if (IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                 ^~~~~~~~~~
/usr/include/netinet6/in6.h:238:42: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
                                                ^
slirp/ip6_icmp.c:275:34: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    if (IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                 ^~~~~~~~~~
/usr/include/netinet6/in6.h:239:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
                                               ^
slirp/ip6_icmp.c:275:34: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    if (IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                 ^~~~~~~~~~
/usr/include/netinet6/in6.h:240:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
                                               ^
slirp/ip6_icmp.c:275:34: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    if (IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)) {
                                 ^~~~~~~~~~
/usr/include/netinet6/in6.h:241:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
                                               ^
slirp/ip6_icmp.c:294:50: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    ricmp->icmp6_nna.S = !IN6_IS_ADDR_MULTICAST(&rip->ip_dst);
                                                 ^~~~~~~~~~~
/usr/include/netinet6/in6.h:299:36: note: expanded from macro 'IN6_IS_ADDR_MULTICAST'
#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
                                          ^
slirp/ip6_icmp.c:351:44: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && !IN6_IS_ADDR_MULTICAST(&icmp->icmp6_nns.target)
                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet6/in6.h:299:36: note: expanded from macro 'IN6_IS_ADDR_MULTICAST'
#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
                                          ^
slirp/ip6_icmp.c:353:47: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && (!IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)
                                              ^~~~~~~~~~
/usr/include/netinet6/in6.h:238:42: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        ((*(const __uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
                                                ^
slirp/ip6_icmp.c:353:47: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && (!IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)
                                              ^~~~~~~~~~
/usr/include/netinet6/in6.h:239:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
                                               ^
slirp/ip6_icmp.c:353:47: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && (!IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)
                                              ^~~~~~~~~~
/usr/include/netinet6/in6.h:240:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
                                               ^
slirp/ip6_icmp.c:353:47: warning: taking address of packed member 'ip_src' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && (!IN6_IS_ADDR_UNSPECIFIED(&ip->ip_src)
                                              ^~~~~~~~~~
/usr/include/netinet6/in6.h:241:41: note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'
        (*(const __uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
                                               ^
slirp/ip6_icmp.c:354:53: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                    || in6_solicitednode_multicast(&ip->ip_dst))) {
                                                    ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:91:20: note:
      expanded from macro 'in6_solicitednode_multicast'
    (in6_equal_net(a, &(struct in6_addr)SOLICITED_NODE_PREFIX, 104))
                   ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
     ~~~~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:76:21: note:
      expanded from macro 'in6_equal_router'
    ((in6_equal_net(a, &slirp->vprefix_addr6, slirp->vprefix_len)\
                    ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
     ~~~~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:77:25: note:
      expanded from macro 'in6_equal_router'
      && in6_equal_mach(a, &slirp->vhost_addr6, slirp->vprefix_len))\
                        ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
     ~~~~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:78:21: note:
      expanded from macro 'in6_equal_router'
  || (in6_equal_net(a, &(struct in6_addr)LINKLOCAL_ADDR, 64)\
                    ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
     ~~~~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:79:25: note:
      expanded from macro 'in6_equal_router'
      && in6_equal_mach(a, &slirp->vhost_addr6, 64)))
                        ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                            ~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:82:21: note:
      expanded from macro 'in6_equal_dns'
    ((in6_equal_net(a, &slirp->vprefix_addr6, slirp->vprefix_len)\
                    ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                            ~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:83:25: note:
      expanded from macro 'in6_equal_dns'
      && in6_equal_mach(a, &slirp->vnameserver_addr6, slirp->vprefix_len))\
                        ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                            ~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:84:21: note:
      expanded from macro 'in6_equal_dns'
  || (in6_equal_net(a, &(struct in6_addr)LINKLOCAL_ADDR, 64)\
                    ^
slirp/ip6_icmp.c:355:33: warning: taking address of packed member 'target' of class or
      structure 'ndp_ns' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
            if (in6_equal_host(&icmp->icmp6_nns.target)) {
                ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                            ~~~~~~~~~~~~~~^~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:85:25: note:
      expanded from macro 'in6_equal_dns'
      && in6_equal_mach(a, &slirp->vnameserver_addr6, 64)))
                        ^
slirp/ip6_icmp.c:368:44: warning: taking address of packed member 'target' of class or
      structure 'ndp_na' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && !IN6_IS_ADDR_MULTICAST(&icmp->icmp6_nna.target)
                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet6/in6.h:299:36: note: expanded from macro 'IN6_IS_ADDR_MULTICAST'
#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
                                          ^
slirp/ip6_icmp.c:369:45: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                && (!IN6_IS_ADDR_MULTICAST(&ip->ip_dst)
                                            ^~~~~~~~~~
/usr/include/netinet6/in6.h:299:36: note: expanded from macro 'IN6_IS_ADDR_MULTICAST'
#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
                                          ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                      ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:76:21: note:
      expanded from macro 'in6_equal_router'
    ((in6_equal_net(a, &slirp->vprefix_addr6, slirp->vprefix_len)\
                    ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                      ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:77:25: note:
      expanded from macro 'in6_equal_router'
      && in6_equal_mach(a, &slirp->vhost_addr6, slirp->vprefix_len))\
                        ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                      ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:78:21: note:
      expanded from macro 'in6_equal_router'
  || (in6_equal_net(a, &(struct in6_addr)LINKLOCAL_ADDR, 64)\
                    ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:23: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                      ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:79:25: note:
      expanded from macro 'in6_equal_router'
      && in6_equal_mach(a, &slirp->vhost_addr6, 64)))
                        ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                                          ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:82:21: note:
      expanded from macro 'in6_equal_dns'
    ((in6_equal_net(a, &slirp->vprefix_addr6, slirp->vprefix_len)\
                    ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                                          ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:83:25: note:
      expanded from macro 'in6_equal_dns'
      && in6_equal_mach(a, &slirp->vnameserver_addr6, slirp->vprefix_len))\
                        ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                                          ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:84:21: note:
      expanded from macro 'in6_equal_dns'
  || (in6_equal_net(a, &(struct in6_addr)LINKLOCAL_ADDR, 64)\
                    ^
slirp/ip6_icmp.c:414:29: warning: taking address of packed member 'ip_dst' of class or
      structure 'ip6' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (in6_equal_host(&ip->ip_dst)) {
                            ^~~~~~~~~~
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:88:43: note:
      expanded from macro 'in6_equal_host'
    (in6_equal_router(a) || in6_equal_dns(a))
                                          ^
/Users/john/Documents/Development/Projects/Qemu/qemu-git/slirp/ip6.h:85:25: note:
      expanded from macro 'in6_equal_dns'
      && in6_equal_mach(a, &slirp->vnameserver_addr6, 64)))
                        ^

slirp/ip_input.c:159:43: warning: taking address of packed member 'ip_link' of class or
      structure 'ipq' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
                                                        ^~~~~~~~~~~~~~~~~~
slirp/ip_input.c:441:18: warning: taking address of packed member 'ip_link' of class or
      structure 'ipq' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
    while (l != &slirp->ipq.ip_link) {
                 ^~~~~~~~~~~~~~~~~~
2 warnings generated.
34 warnings generated.

slirp/slirp.c:403:19: warning: taking address of packed member 'ip_link' of class or
      structure 'ipq' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
                (&slirp->ipq.ip_link != slirp->ipq.ip_link.next));
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Samuel Thibault-9
Hello,

Programmingkid, on jeu. 10 août 2017 16:44:19 -0400, wrote:
> While compiling I saw these error messages:
>
> slirp/ip6_icmp.c:79:32: warning: taking address of packed member 'ip_src' of class or
>       structure 'ip6' may result in an unaligned pointer value
>       [-Waddress-of-packed-member]
>     if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) ||
>                                ^~~~~~~~~~

> slirp/ip_input.c:159:43: warning: taking address of packed member 'ip_link' of class or
>       structure 'ipq' may result in an unaligned pointer value
>       [-Waddress-of-packed-member]
>                 for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
>                                                         ^~~~~~~~~~~~~~~~~~

Well, if the compiler was counting well, it would notice that the
structure are made so that even with packing, fields always get aligned
on proper bounds.

(and no, we don't want to remove QEMU_PACKED from struct ip6, at least,
since it *has* to be packed to match the ipv6 headers).

Samuel

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Peter Maydell-5
On 11 August 2017 at 22:58, Samuel Thibault <[hidden email]> wrote:

> Hello,
>
> Programmingkid, on jeu. 10 août 2017 16:44:19 -0400, wrote:
>> While compiling I saw these error messages:
>>
>> slirp/ip6_icmp.c:79:32: warning: taking address of packed member 'ip_src' of class or
>>       structure 'ip6' may result in an unaligned pointer value
>>       [-Waddress-of-packed-member]
>>     if (IN6_IS_ADDR_MULTICAST(&ip->ip_src) ||
>>                                ^~~~~~~~~~
>
>> slirp/ip_input.c:159:43: warning: taking address of packed member 'ip_link' of class or
>>       structure 'ipq' may result in an unaligned pointer value
>>       [-Waddress-of-packed-member]
>>                 for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
>>                                                         ^~~~~~~~~~~~~~~~~~
>
> Well, if the compiler was counting well, it would notice that the
> structure are made so that even with packing, fields always get aligned
> on proper bounds.

The utility of the warning is that it means you get told
about stuff that might break on other architectures. Eg
x86's alignment restrictions are practically nonexistent
but sparc is much more restrictive. It's better to get
warnings on all hosts so these things can be cleaned
up rather than have them only be warnings on the less
commonly used hosts where nobody will notice them.

(GCC ideally ought to warn about this but doesn't:
that's a bug/missing feature in gcc.)

That said, some of these are a bit odd -- comparing
a pointer value should be fine, as should using
a pointer to a packed struct field inside a
function -- it's only when that pointer is cast
to a non-packed-pointer-type (including by passing
it to another function) that the compiler loses the
information that the pointer is potentially unaligned.

thanks
-- PMM

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Samuel Thibault-9
Peter Maydell, on sam. 12 août 2017 11:53:20 +0100, wrote:
> The utility of the warning is that it means you get told
> about stuff that might break on other architectures.

Sure, I understand that. But here all fields are aligned on their size
inside the packed structure. So there can't be alignment issues, and the
compiler should be able to determine that.

Samuel

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Peter Maydell-5
On 12 August 2017 at 12:04, Samuel Thibault <[hidden email]> wrote:
> Peter Maydell, on sam. 12 août 2017 11:53:20 +0100, wrote:
>> The utility of the warning is that it means you get told
>> about stuff that might break on other architectures.
>
> Sure, I understand that. But here all fields are aligned on their size
> inside the packed structure. So there can't be alignment issues, and the
> compiler should be able to determine that.

Alignment is architecture-dependent, and the compiler
can't know the alignment requirements for every
architecture. There's no rule in C that says that
uint16_t only needs 2 byte alignment and not 4 on
some hosts.

(Also I just noticed 'struct ip6' uses bitfields:
that's badly non-portable if it's trying to
match an on-the-wire layout.)

thanks
-- PMM

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Samuel Thibault-9
Peter Maydell, on sam. 12 août 2017 12:18:16 +0100, wrote:

> On 12 August 2017 at 12:04, Samuel Thibault <[hidden email]> wrote:
> > Peter Maydell, on sam. 12 août 2017 11:53:20 +0100, wrote:
> >> The utility of the warning is that it means you get told
> >> about stuff that might break on other architectures.
> >
> > Sure, I understand that. But here all fields are aligned on their size
> > inside the packed structure. So there can't be alignment issues, and the
> > compiler should be able to determine that.
>
> Alignment is architecture-dependent, and the compiler
> can't know the alignment requirements for every
> architecture.

Sure.

> There's no rule in C that says that uint16_t only needs 2 byte
> alignment and not 4 on some hosts.

Are there really systems where that happens?  Such systems would have to
pad uint16_t arrays then, really?

> (Also I just noticed 'struct ip6' uses bitfields:
> that's badly non-portable if it's trying to
> match an on-the-wire layout.)

struct ip has been doing so for so long too.

I'm not saying the code is perfectly portable, I'm just saying it's
portable enough for being both practical and readable.

Samuel

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Eric Blake
On 08/12/2017 06:29 AM, Samuel Thibault wrote:
>>
>> Alignment is architecture-dependent, and the compiler
>> can't know the alignment requirements for every
>> architecture.
>
> Sure.

True, but we can at least guess alignments that don't require padding,
and then be told by the compiler if our guess was wrong when porting to
a new system, and update our guess accordingly with more ifdefs (struct
ip6 is already using ifdef HOST_WORDS_BIGENDIAN for that reason).

>
>> There's no rule in C that says that uint16_t only needs 2 byte
>> alignment and not 4 on some hosts.
>
> Are there really systems where that happens?  Such systems would have to
> pad uint16_t arrays then, really?

uint16_least_t occupies only 2 bytes, but C and POSIX allow systems
where uint16_t is larger than 16 bits (most likely, 32 bits).  I don't
personally know of such a system; and it's most-likely to be a non-POSIX
system (perhaps one where sizeof(int) == 1 because the smallest
addressable integer is 32 bits).

>
>> (Also I just noticed 'struct ip6' uses bitfields:
>> that's badly non-portable if it's trying to
>> match an on-the-wire layout.)
>
> struct ip has been doing so for so long too.
>
> I'm not saying the code is perfectly portable, I'm just saying it's
> portable enough for being both practical and readable.

Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use

struct ip6 {
...
};
QEMU_BUG_ON(sizeof(struct ip6) != 32);

so that the compiler explicitly chokes if it introduced any padding, and
then we know all our accesses are naturally aligned which shuts up the
warning.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


signature.asc (632 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Samuel Thibault-9
Eric Blake, on sam. 12 août 2017 06:41:30 -0500, wrote:
> Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use
>
> struct ip6 {
> ...
> };
> QEMU_BUG_ON(sizeof(struct ip6) != 32);

That's an interesting way indeed.  I however wonder whether there may be
not-so-uncommon systems where the compiler aligns some fields just for
performance or such.

Samuel

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Eric Blake
On 08/12/2017 06:47 AM, Samuel Thibault wrote:

> Eric Blake, on sam. 12 août 2017 06:41:30 -0500, wrote:
>> Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use
>>
>> struct ip6 {
>> ...
>> };
>> QEMU_BUG_ON(sizeof(struct ip6) != 32);
>
> That's an interesting way indeed.  I however wonder whether there may be
> not-so-uncommon systems where the compiler aligns some fields just for
> performance or such.
If it does, the BUG_ON will flag it, and we'll deal with it as needed
for that platform, perhaps by adding:

...
}
#ifdef WEIRD_PLATFORM
  QEMU_PACKED
#endif
 ;
QEMU_BUG_ON(...);

But as long as the BUG_ON doesn't flag anything, we can use the struct
as-is.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


signature.asc (632 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Philippe Mathieu-Daudé
In reply to this post by Eric Blake
Hi Eric,

On 08/12/2017 08:41 AM, Eric Blake wrote:

> Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use
>
> struct ip6 {
> ...
> };
> QEMU_BUG_ON(sizeof(struct ip6) != 32);
>
> so that the compiler explicitly chokes if it introduced any padding, and
> then we know all our accesses are naturally aligned which shuts up the
> warning.

Following your suggestion I tried:

#define QEMU_BUG_STRUCT_UNALIGNED(s) \
         QEMU_BUILD_BUG_ON(sizeof(s) != sizeof(s QEMU_PACKED))

QEMU_BUG_STRUCT_UNALIGNED(struct ip6);

but this gives:

qemu/slirp/ip6.h:157:1: warning: 'packed' attribute ignored when parsing
type [-Wignored-attributes]
QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
qemu/slirp/ip6.h:155:49: note: expanded from macro
'QEMU_BUG_STRUCT_UNALIGNED'
         QEMU_BUILD_BUG_ON(sizeof(s) != sizeof(s QEMU_PACKED))
                                                 ^~~~~~~~~~~
qemu/include/qemu/compiler.h:40:37: note: expanded from macro 'QEMU_PACKED'
# define QEMU_PACKED __attribute__((packed))
                                     ^~~~~~
1 warning generated.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: SLIRP warning messages displayed while compiling

Eric Blake
On 08/12/2017 10:38 AM, Philippe Mathieu-Daudé wrote:

> Hi Eric,
>
> On 08/12/2017 08:41 AM, Eric Blake wrote:
>> Here's an idea:  Instead of using struct ip6 { ... } QEMU_PACKED, use
>>
>> struct ip6 {
>> ...
>> };
>> QEMU_BUG_ON(sizeof(struct ip6) != 32);
>>
>> so that the compiler explicitly chokes if it introduced any padding, and
>> then we know all our accesses are naturally aligned which shuts up the
>> warning.
>
> Following your suggestion I tried:
>
> #define QEMU_BUG_STRUCT_UNALIGNED(s) \
>         QEMU_BUILD_BUG_ON(sizeof(s) != sizeof(s QEMU_PACKED))
I don't think gcc likes that (you can't just add attribute packed in
arbitrary places, but only where the type is declared).

>
> QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
>
> but this gives:
>
> qemu/slirp/ip6.h:157:1: warning: 'packed' attribute ignored when parsing
> type [-Wignored-attributes]
> QEMU_BUG_STRUCT_UNALIGNED(struct ip6);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Indeed, there's the evidence that your attempt at a shortcut didn't
work. My proposal was to put in a hard-coded number, rather than try to
make the compiler compute two variants of the type and check that they
occupy the same space (although I agree with your idea that if you CAN
get the compiler to do that, it's nicer than hand-computing the number
to compare against).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


signature.asc (632 bytes) Download Attachment
Loading...