git: asr(4): Fix -Wint-to-pointer and -Warray-bounds warnings

Aaron LI aly at crater.dragonflybsd.org
Wed Oct 14 07:06:40 PDT 2026


commit 934a7c6585a52e4e4716665abdbaf8f19720761a
Author: Aaron LI <aly at aaronly.me>
Date:   Wed Oct 14 19:13:28 2026 +0800

    asr(4): Fix -Wint-to-pointer and -Warray-bounds warnings
    
    This does fix any real bug, but silence the following warnings from GCC
    12.5.  This also fixes buildworld that was broken by the previous commit,
    which revealed the -Wint-to-pointer warning with GCC 8 as well.
    
    ```
    /usr/src/sys/dev/raid/asr/asr.c: In function 'ASR_queue_i':
    /usr/src/sys/dev/raid/asr/asr.c:3353:42: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     3353 |                         elm->UserSpace = (caddr_t)
          |                                          ^
    In file included from /usr/src/sys/dev/raid/asr/i2otypes.h:91,
                     from /usr/src/sys/dev/raid/asr/i2omsg.h:120,
                     from /usr/src/sys/dev/raid/asr/i2oexec.h:96,
                     from /usr/src/sys/dev/raid/asr/asr.c:149:
    /usr/src/sys/dev/raid/asr/asr.c: In function 'ASR_acquireLct':
    /usr/src/sys/dev/raid/asr/asr.c:1476:52: warning: array subscript 'struct _I2O_EXEC_LCT_NOTIFY_MESSAGE[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     1476 |         I2O_MESSAGE_FRAME_setFunction(&(Message_Ptr->StdMessageFrame),
          |                                                    ^~
    /usr/src/sys/dev/raid/asr/i2odep.h:261:33: note: in definition of macro '_F_setFunc'
      261 | # define _F_setFunc(w,x,y,z)  ((w)->y = (z))
          |                                 ^
    /usr/src/sys/dev/raid/asr/asr.c:1476:9: note: in expansion of macro 'I2O_MESSAGE_FRAME_setFunction'
     1476 |         I2O_MESSAGE_FRAME_setFunction(&(Message_Ptr->StdMessageFrame),
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from /usr/src/sys/dev/raid/asr/asr.c:118:
    In function '__kmalloc',
        inlined from 'ASR_acquireLct' at /usr/src/sys/dev/raid/asr/asr.c:1468:51:
    /usr/src/sys/sys/malloc.h:287:17: note: object of size 32 allocated by '_kmalloc'
      287 |         return (_kmalloc(_size, _type, _flags));
          |                ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sys/dev/raid/asr/asr.c: In function 'ASR_acquireLct':
    /usr/src/sys/dev/raid/asr/asr.c:1373:37: warning: array subscript 'struct _I2O_SG_ELEMENT[1]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     1373 |           &(((PI2O_SG_ELEMENT)(SGL))->u.Simple[Index].FlagsCount), \
          |                                     ^~
    /usr/src/sys/dev/raid/asr/i2odep.h:263:33: note: in definition of macro '_F_setCount'
      263 | # define _F_setCount(w,x,y,z) ((w)->y = (z))
          |                                 ^
    /usr/src/sys/dev/raid/asr/asr.c:1372:9: note: in expansion of macro 'I2O_FLAGS_COUNT_setCount'
     1372 |         I2O_FLAGS_COUNT_setCount(                                  \
          |         ^~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sys/dev/raid/asr/asr.c:1484:9: note: in expansion of macro 'SG'
     1484 |         SG(&(Message_Ptr->SGL), 0,
          |         ^~
    In function '__kmalloc',
        inlined from 'ASR_acquireLct' at /usr/src/sys/dev/raid/asr/asr.c:1468:51:
    /usr/src/sys/sys/malloc.h:287:17: note: at offset 24 into object of size 32 allocated by '_kmalloc'
      287 |         return (_kmalloc(_size, _type, _flags));
          |                ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sys/dev/raid/asr/asr.c: In function 'ASR_acquireLct':
    /usr/src/sys/dev/raid/asr/asr.c:1376:37: warning: array subscript 'struct _I2O_SG_ELEMENT[1]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
     1376 |           &(((PI2O_SG_ELEMENT)(SGL))->u.Simple[Index].FlagsCount), \
          |                                     ^~
    /usr/src/sys/dev/raid/asr/i2odep.h:265:33: note: in definition of macro '_F_setFlags'
      265 | # define _F_setFlags(w,x,y,z) ((w)->y = (z))
          |                                 ^
    /usr/src/sys/dev/raid/asr/asr.c:1375:9: note: in expansion of macro 'I2O_FLAGS_COUNT_setFlags'
     1375 |         I2O_FLAGS_COUNT_setFlags(                                  \
          |         ^~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sys/dev/raid/asr/asr.c:1484:9: note: in expansion of macro 'SG'
     1484 |         SG(&(Message_Ptr->SGL), 0,
          |         ^~
    In function '__kmalloc',
        inlined from 'ASR_acquireLct' at /usr/src/sys/dev/raid/asr/asr.c:1468:51:
    /usr/src/sys/sys/malloc.h:287:17: note: at offset 24 into object of size 32 allocated by '_kmalloc'
      287 |         return (_kmalloc(_size, _type, _flags));
          |                ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In function 'ASR_init_message',
        inlined from 'asr_action' at /usr/src/sys/dev/raid/asr/asr.c:2714:22:
    /usr/src/sys/dev/raid/asr/asr.c:1812:35: warning: array subscript 58 is above array bounds of 'I2O_SGE_SIMPLE_ELEMENT[2]' {aka 'struct _I2O_SGE_SIMPLE_ELEMENT[2]'} [-Warray-bounds]
     1812 |         while ((len > 0) && (sg < &((PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE)
          |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1813 |           Message_Ptr)->SGL.u.Simple[SG_SIZE])) {
          |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/src/sys/dev/raid/asr/i2omsg.h: In function 'asr_action':
    /usr/src/sys/dev/raid/asr/i2omsg.h:927:44: note: while referencing 'Simple'
      927 |        I2O_SGE_SIMPLE_ELEMENT              Simple[2];
          |                                            ^~~~~~
    ```

Summary of changes:
 sys/dev/raid/asr/asr.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/934a7c6585a52e4e4716665abdbaf8f19720761a


-- 
DragonFly BSD source repository


More information about the Commits mailing list