drivers/scsi/mpt3sas/mpt3sas_base.c:1648:61: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 32

From: kernel test robot
Date: Mon Nov 06 2023 - 17:49:38 EST


Hi Sreekanth,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d2f51b3516dade79269ff45eae2a7668ae711b25
commit: d357e84d65dfcdb502fdb1aaab2873a82a828db5 mpt3sas: Define 'hba_mpi_version_belonged' IOC variable
date: 8 years ago
config: x86_64-buildonly-randconfig-006-20230911 (https://download.01.org/0day-ci/archive/20231107/202311070619.k72DqC4f-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231107/202311070619.k72DqC4f-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311070619.k72DqC4f-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from include/linux/kobject.h:21,
from include/linux/module.h:17,
from drivers/scsi/mpt3sas/mpt3sas_base.c:47:
include/linux/sysfs.h: In function 'sysfs_get_dirent':
include/linux/sysfs.h:496:44: warning: pointer targets in passing argument 2 of 'kernfs_find_and_get' differ in signedness [-Wpointer-sign]
496 | return kernfs_find_and_get(parent, name);
| ^~~~
| |
| const unsigned char *
In file included from include/linux/sysfs.h:15:
include/linux/kernfs.h:428:57: note: expected 'const char *' but argument is of type 'const unsigned char *'
428 | kernfs_find_and_get(struct kernfs_node *kn, const char *name)
| ~~~~~~~~~~~~^~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_assign_reply_queues':
drivers/scsi/mpt3sas/mpt3sas_base.c:1713:57: warning: suggest braces around empty body in an 'if' statement [-Wempty-body]
1713 | ioc->name, reply_q->vector));
| ^
drivers/scsi/mpt3sas/mpt3sas_base.c: At top level:
drivers/scsi/mpt3sas/mpt3sas_base.c:1820:1: warning: no previous declaration for 'mpt3sas_base_unmap_resources' [-Wmissing-declarations]
1820 | mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_display_ioc_capabilities':
drivers/scsi/mpt3sas/mpt3sas_base.c:2477:36: warning: pointer targets in passing argument 2 of 'strncpy' differ in signedness [-Wpointer-sign]
2477 | strncpy(desc, ioc->manu_pg0.ChipName, 16);
| ~~~~~~~~~~~~~^~~~~~~~~
| |
| U8 * {aka unsigned char *}
In file included from include/linux/bitmap.h:8,
from include/linux/cpumask.h:11,
from arch/x86/include/asm/cpumask.h:4,
from arch/x86/include/asm/msr.h:10,
from arch/x86/include/asm/processor.h:20,
from arch/x86/include/asm/thread_info.h:52,
from include/linux/thread_info.h:54,
from arch/x86/include/asm/preempt.h:6,
from include/linux/preempt.h:64,
from include/linux/spinlock.h:50,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/linux/stat.h:18,
from include/linux/module.h:10:
include/linux/string.h:23:30: note: expected 'const char *' but argument is of type 'U8 *' {aka 'unsigned char *'}
23 | extern char * strncpy(char *,const char *, __kernel_size_t);
| ^~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_handshake_req_reply_wait':
drivers/scsi/mpt3sas/mpt3sas_base.c:3503:13: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
3503 | u16 dummy;
| ^~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function 'mpt3sas_base_sas_iounit_control':
drivers/scsi/mpt3sas/mpt3sas_base.c:3628:23: warning: variable 'timeleft' set but not used [-Wunused-but-set-variable]
3628 | unsigned long timeleft;
| ^~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function 'mpt3sas_base_scsi_enclosure_processor':
drivers/scsi/mpt3sas/mpt3sas_base.c:3732:23: warning: variable 'timeleft' set but not used [-Wunused-but-set-variable]
3732 | unsigned long timeleft;
| ^~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_send_port_enable':
drivers/scsi/mpt3sas/mpt3sas_base.c:4174:23: warning: variable 'timeleft' set but not used [-Wunused-but-set-variable]
4174 | unsigned long timeleft;
| ^~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_event_notification':
drivers/scsi/mpt3sas/mpt3sas_base.c:4399:42: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
4399 | ioc->name, __func__));
| ^
drivers/scsi/mpt3sas/mpt3sas_base.c:4355:23: warning: variable 'timeleft' set but not used [-Wunused-but-set-variable]
4355 | unsigned long timeleft;
| ^~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_request_irq':
>> drivers/scsi/mpt3sas/mpt3sas_base.c:1648:61: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
1648 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
| ^~
drivers/scsi/mpt3sas/mpt3sas_base.c:1648:58: note: directive argument in the range [0, 255]
1648 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
| ^~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:1648:17: note: 'snprintf' output between 2 and 35 bytes into a destination of size 32
1648 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1649 | driver_name, ioc->id);
| ~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:1645:61: warning: '%d' directive output may be truncated writing between 1 and 3 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
1645 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~
drivers/scsi/mpt3sas/mpt3sas_base.c:1645:58: note: directive argument in the range [0, 255]
1645 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~
drivers/scsi/mpt3sas/mpt3sas_base.c:1645:58: note: directive argument in the range [0, 254]
drivers/scsi/mpt3sas/mpt3sas_base.c:1645:17: note: 'snprintf' output between 8 and 43 bytes into a destination of size 32
1645 | snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1646 | driver_name, ioc->id, index);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +1648 drivers/scsi/mpt3sas/mpt3sas_base.c

f92363d1235949 Sreekanth Reddy 2012-11-30 1614
f92363d1235949 Sreekanth Reddy 2012-11-30 1615 /**
f92363d1235949 Sreekanth Reddy 2012-11-30 1616 * _base_request_irq - request irq
f92363d1235949 Sreekanth Reddy 2012-11-30 1617 * @ioc: per adapter object
f92363d1235949 Sreekanth Reddy 2012-11-30 1618 * @index: msix index into vector table
f92363d1235949 Sreekanth Reddy 2012-11-30 1619 * @vector: irq vector
f92363d1235949 Sreekanth Reddy 2012-11-30 1620 *
f92363d1235949 Sreekanth Reddy 2012-11-30 1621 * Inserting respective reply_queue into the list.
f92363d1235949 Sreekanth Reddy 2012-11-30 1622 */
f92363d1235949 Sreekanth Reddy 2012-11-30 1623 static int
f92363d1235949 Sreekanth Reddy 2012-11-30 1624 _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index, u32 vector)
f92363d1235949 Sreekanth Reddy 2012-11-30 1625 {
f92363d1235949 Sreekanth Reddy 2012-11-30 1626 struct adapter_reply_queue *reply_q;
f92363d1235949 Sreekanth Reddy 2012-11-30 1627 int r;
f92363d1235949 Sreekanth Reddy 2012-11-30 1628
f92363d1235949 Sreekanth Reddy 2012-11-30 1629 reply_q = kzalloc(sizeof(struct adapter_reply_queue), GFP_KERNEL);
f92363d1235949 Sreekanth Reddy 2012-11-30 1630 if (!reply_q) {
f92363d1235949 Sreekanth Reddy 2012-11-30 1631 pr_err(MPT3SAS_FMT "unable to allocate memory %d!\n",
f92363d1235949 Sreekanth Reddy 2012-11-30 1632 ioc->name, (int)sizeof(struct adapter_reply_queue));
f92363d1235949 Sreekanth Reddy 2012-11-30 1633 return -ENOMEM;
f92363d1235949 Sreekanth Reddy 2012-11-30 1634 }
f92363d1235949 Sreekanth Reddy 2012-11-30 1635 reply_q->ioc = ioc;
f92363d1235949 Sreekanth Reddy 2012-11-30 1636 reply_q->msix_index = index;
f92363d1235949 Sreekanth Reddy 2012-11-30 1637 reply_q->vector = vector;
14b3114d940cdc Sreekanth Reddy 2015-01-12 1638
14b3114d940cdc Sreekanth Reddy 2015-01-12 1639 if (!alloc_cpumask_var(&reply_q->affinity_hint, GFP_KERNEL))
14b3114d940cdc Sreekanth Reddy 2015-01-12 1640 return -ENOMEM;
14b3114d940cdc Sreekanth Reddy 2015-01-12 1641 cpumask_clear(reply_q->affinity_hint);
14b3114d940cdc Sreekanth Reddy 2015-01-12 1642
f92363d1235949 Sreekanth Reddy 2012-11-30 1643 atomic_set(&reply_q->busy, 0);
f92363d1235949 Sreekanth Reddy 2012-11-30 1644 if (ioc->msix_enable)
f92363d1235949 Sreekanth Reddy 2012-11-30 1645 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d-msix%d",
d357e84d65dfcd Sreekanth Reddy 2015-11-11 1646 driver_name, ioc->id, index);
f92363d1235949 Sreekanth Reddy 2012-11-30 1647 else
f92363d1235949 Sreekanth Reddy 2012-11-30 @1648 snprintf(reply_q->name, MPT_NAME_LENGTH, "%s%d",
d357e84d65dfcd Sreekanth Reddy 2015-11-11 1649 driver_name, ioc->id);
f92363d1235949 Sreekanth Reddy 2012-11-30 1650 r = request_irq(vector, _base_interrupt, IRQF_SHARED, reply_q->name,
f92363d1235949 Sreekanth Reddy 2012-11-30 1651 reply_q);
f92363d1235949 Sreekanth Reddy 2012-11-30 1652 if (r) {
f92363d1235949 Sreekanth Reddy 2012-11-30 1653 pr_err(MPT3SAS_FMT "unable to allocate interrupt %d!\n",
f92363d1235949 Sreekanth Reddy 2012-11-30 1654 reply_q->name, vector);
f92363d1235949 Sreekanth Reddy 2012-11-30 1655 kfree(reply_q);
f92363d1235949 Sreekanth Reddy 2012-11-30 1656 return -EBUSY;
f92363d1235949 Sreekanth Reddy 2012-11-30 1657 }
f92363d1235949 Sreekanth Reddy 2012-11-30 1658
f92363d1235949 Sreekanth Reddy 2012-11-30 1659 INIT_LIST_HEAD(&reply_q->list);
f92363d1235949 Sreekanth Reddy 2012-11-30 1660 list_add_tail(&reply_q->list, &ioc->reply_queue_list);
f92363d1235949 Sreekanth Reddy 2012-11-30 1661 return 0;
f92363d1235949 Sreekanth Reddy 2012-11-30 1662 }
f92363d1235949 Sreekanth Reddy 2012-11-30 1663

:::::: The code at line 1648 was first introduced by commit
:::::: f92363d12359498f9a9960511de1a550f0ec41c2 [SCSI] mpt3sas: add new driver supporting 12GB SAS

:::::: TO: Sreekanth Reddy <Sreekanth.Reddy@xxxxxxx>
:::::: CC: James Bottomley <JBottomley@xxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki