linux/drivers/scsi/pm8001
Arnd Bergmann c2255ece2b scsi: pm8001: Avoid -Wrestrict warning
On some configurations, gcc warns about overlapping source and destination
arguments to snprintf:

drivers/scsi/pm8001/pm8001_init.c: In function 'pm8001_request_msix':
drivers/scsi/pm8001/pm8001_init.c:977:3: error: 'snprintf' argument 4 may overlap destination object 'pm8001_ha' [-Werror=restrict]
  977 |   snprintf(drvname, len, "%s-%d", pm8001_ha->name, i);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/pm8001/pm8001_init.c:962:56: note: destination object referenced by 'restrict'-qualified argument 1 was declared here
  962 | static u32 pm8001_request_msix(struct pm8001_hba_info *pm8001_ha)
      |                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~

I first assumed this was a gcc bug, as that should not happen, but a
reduced test case makes it clear that this happens when the loop counter is
not bounded by the array size.

Help the compiler out by adding an explicit limit here to make the code
slightly more robust and avoid the warning.

Link: https://godbolt.org/z/6T1qPM
Link: https://lore.kernel.org/r/20210323125458.1825564-1-arnd@kernel.org
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-03-24 23:16:14 -04:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pm80xx_hwi.c scsi: pm8001: Fix a bunch of doc-rotted function headers 2021-03-15 22:14:53 -04:00
pm80xx_hwi.h scsi: pm80xx: Check for fatal error 2021-01-13 00:02:01 -05:00
pm8001_chips.h
pm8001_ctl.c scsi: pm8001: Fix incorrectly named functions in headers 2021-03-15 22:14:51 -04:00
pm8001_ctl.h
pm8001_defs.h scsi: pm80xx: Increase the number of outstanding I/O supported to 1024 2020-10-07 23:50:04 -04:00
pm8001_hwi.c scsi: pm8001: Fix some misnamed function descriptions 2021-03-15 22:14:52 -04:00
pm8001_hwi.h scsi: pm80xx: Fix for phy enable/disable functionality 2018-09-11 21:13:08 -04:00
pm8001_init.c scsi: pm8001: Avoid -Wrestrict warning 2021-03-24 23:16:14 -04:00
pm8001_sas.c scsi: pm8001: Provide function name 'pm8001_I_T_nexus_reset()' in header 2021-03-15 22:14:51 -04:00
pm8001_sas.h scsi: pm80xx: Remove list entry from pm8001_ccb_info 2021-03-09 23:22:03 -05:00