The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>
Subject: drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument
Date: Wed, 10 Jan 2024 05:43:33 +0800	[thread overview]
Message-ID: <202401100527.L7RokChn-lkp@intel.com> (raw)

Hi Chaitanya,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   9f8413c4a66f2fb776d3dc3c9ed20bf435eb305e
commit: d86481e924a7d6e8a40477ffa98077c6c0d77ed5 nvmet: use min of device_path and disk len
date:   2 years, 11 months ago
config: arm64-randconfig-002-20240106 (https://download.01.org/0day-ci/archive/20240110/202401100527.L7RokChn-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240110/202401100527.L7RokChn-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401100527.L7RokChn-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/nvme/target/core.c:14:
   In function '__assign_req_name',
       inlined from 'trace_event_raw_event_nvmet_req_init' at drivers/nvme/target/./trace.h:61:1:
>> drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
      56 |         strncpy(name, req->ns->device_path,
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/kernel.h:14,
                    from include/linux/list.h:9,
                    from include/linux/module.h:12,
                    from drivers/nvme/target/core.c:7:
   drivers/nvme/target/trace.h:57:46: note: length computed here
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
   include/linux/minmax.h:38:39: note: in definition of macro '__cmp_once'
      38 |                 typeof(y) unique_y = (y);               \
         |                                       ^
   include/linux/minmax.h:110:33: note: in expansion of macro '__careful_cmp'
     110 | #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
         |                                 ^~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:17: note: in expansion of macro 'min_t'
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ^~~~~
   In function '__assign_req_name',
       inlined from 'trace_event_raw_event_nvmet_req_complete' at drivers/nvme/target/./trace.h:103:1:
>> drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
      56 |         strncpy(name, req->ns->device_path,
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:46: note: length computed here
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
   include/linux/minmax.h:38:39: note: in definition of macro '__cmp_once'
      38 |                 typeof(y) unique_y = (y);               \
         |                                       ^
   include/linux/minmax.h:110:33: note: in expansion of macro '__careful_cmp'
     110 | #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
         |                                 ^~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:17: note: in expansion of macro 'min_t'
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ^~~~~
   In function '__assign_req_name',
       inlined from 'perf_trace_nvmet_req_complete' at drivers/nvme/target/./trace.h:103:1:
>> drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
      56 |         strncpy(name, req->ns->device_path,
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:46: note: length computed here
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
   include/linux/minmax.h:38:39: note: in definition of macro '__cmp_once'
      38 |                 typeof(y) unique_y = (y);               \
         |                                       ^
   include/linux/minmax.h:110:33: note: in expansion of macro '__careful_cmp'
     110 | #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
         |                                 ^~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:17: note: in expansion of macro 'min_t'
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ^~~~~
   In function '__assign_req_name',
       inlined from 'perf_trace_nvmet_req_init' at drivers/nvme/target/./trace.h:61:1:
>> drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
      56 |         strncpy(name, req->ns->device_path,
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:46: note: length computed here
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
   include/linux/minmax.h:38:39: note: in definition of macro '__cmp_once'
      38 |                 typeof(y) unique_y = (y);               \
         |                                       ^
   include/linux/minmax.h:110:33: note: in expansion of macro '__careful_cmp'
     110 | #define min_t(type, x, y)       __careful_cmp((type)(x), (type)(y), <)
         |                                 ^~~~~~~~~~~~~
   drivers/nvme/target/trace.h:57:17: note: in expansion of macro 'min_t'
      57 |                 min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
         |                 ^~~~~


vim +/strncpy +56 drivers/nvme/target/trace.h

    48	
    49	static inline void __assign_req_name(char *name, struct nvmet_req *req)
    50	{
    51		if (!req->ns) {
    52			memset(name, 0, DISK_NAME_LEN);
    53			return;
    54		}
    55	
  > 56		strncpy(name, req->ns->device_path,
    57			min_t(size_t, DISK_NAME_LEN, strlen(req->ns->device_path)));
    58	}
    59	#endif
    60	

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

             reply	other threads:[~2024-01-09 21:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 21:43 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-08-13 15:27 drivers/nvme/target/trace.h:56:9: warning: 'strncpy' specified bound depends on the length of the source argument kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202401100527.L7RokChn-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox