On 9/3/19 11:32 PM, Joe Hershberger wrote:
Hi Heinrich,

On Mon, Sep 2, 2019 at 4:39 PM Heinrich Schuchardt <xypron.g...@gmx.de> wrote:

Hello Joe,

GCC 9.2.1 (of Debian Bullseye) produces the warnings below when building
pine64-lts_defconfig. Is it really necessary to define struct rpc_t as
packed? The structure is composed out of uint32_t only. So shouldn't it
be naturally packed without the attribute?

I guess this won't cause problems on 64-bit with the union sharing
memory, right?

The addresses of all members of a union is the same. See C99 standard
6.2.7.1, paragraph 14.

The alignment requirement on an array is not stricter than on its
elements. Anyway the arrays in the union start at a multiple of 64bit
after the start of the structure.

Both on x86_64 and on arm64 &u.reply.data is 24 bytes after &u without
'packed' - just where you would expect it.

Best regards

Heinrich




net/nfs.c: In function ‘rpc_req’:
net/nfs.c:199:18: error: taking address of packed member of ‘struct
rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
    199 |  p = (uint32_t *)&(rpc_pkt.u.call.data);
        |                  ^~~~~~~~~~~~~~~~~~~~~~
net/nfs.c: In function ‘nfs_readlink_reply’:
net/nfs.c:631:46: error: taking address of packed member of ‘struct
rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
    631 |    nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
        |                               ~~~~~~~~~~~~~~~^~~~~
    LD      drivers/block/built-in.o
net/nfs.c: In function ‘nfs_read_reply’:
net/nfs.c:692:46: error: taking address of packed member of ‘struct
rpc_t’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
    692 |    nfs3_get_attributes_offset(rpc_pkt.u.reply.data);
        |                               ~~~~~~~~~~~~~~~^~~~~

Best regards

Heinrich
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to