git: firewire: Use a union to fix -Warray-bounds warning

Aaron LI aly at crater.dragonflybsd.org
Tue Oct 13 23:15:10 PDT 2026


commit 4d3133cbac374e8a2013c0e785e8473202f12a91
Author: Aaron LI <aly at aaronly.me>
Date:   Wed Oct 14 13:51:57 2026 +0800

    firewire: Use a union to fix -Warray-bounds warning
    
    GCC 12.5 generated the following '-Warray-bounds' warning because the
    'struct fw_pkt' is larger than a 'uint32_t', so introduce a union to
    help the aliasing and fix the warning.
    
    This does fix a real bug, and the change is obtained from NetBSD (GitHub
    commit a30bc076fe2f3e969d7451633acfceedb3412fa3: don't assign struct
    pointers to smaller then structure regions of memory).
    
    ```
    /usr/src/sys/bus/firewire/fwohci.c: In function 'fwohci_arcv_swap.isra':
    /usr/src/sys/bus/firewire/fwohci.c:2598:33: warning: array subscript 'struct fw_pkt[0]' is partly outside array bounds of 'u_int32_t[1]' {aka 'unsigned int[1]'} [-Warray-bounds]
     2598 |         switch (fp0->mode.common.tcode) {
          |                 ~~~~~~~~~~~~~~~~^~~~~~
    /usr/src/sys/bus/firewire/fwohci.c:2586:19: note: object 'ld0' of size 4
     2586 |         u_int32_t ld0;
          |                   ^~~
    ```

Summary of changes:
 sys/bus/firewire/fwohci.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4d3133cbac374e8a2013c0e785e8473202f12a91


-- 
DragonFly BSD source repository


More information about the Commits mailing list