[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <75dfee2a-4b2f-49dd-a1c7-1cc3a9d8dad3@amd.com>
Date: Sun, 5 Nov 2023 21:19:42 -0800
From: "Nelson, Shannon" <shannon.nelson@....com>
To: "Michael S. Tsirkin" <mst@...hat.com>,
kernel test robot <lkp@...el.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive
output may be truncated writing between 2 and 11 bytes into a region of size
6
On 11/5/2023 4:57 AM, Michael S. Tsirkin wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Sat, Nov 04, 2023 at 01:36:05AM +0800, kernel test robot wrote:
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head: 8f6f76a6a29f36d2f3e4510d0bde5046672f6924
>> commit: 9a8864d2a8dc5c49acd66284fd382871d99b5db8 pds_vdpa: pds_vdps.rst and Kconfig
>> date: 4 months ago
>> config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231104/202311040109.RfgJoE7L-lkp@intel.com/config)
>> compiler: alpha-linux-gcc (GCC) 13.2.0
>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/202311040109.RfgJoE7L-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@...el.com>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/202311040109.RfgJoE7L-lkp@intel.com/
>>
>> All warnings (new ones prefixed by >>):
>>
>> drivers/vdpa/pds/debugfs.c: In function 'pds_vdpa_debugfs_add_vdpadev':
>>>> drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6 [-Wformat-truncation=]
>> 269 | snprintf(name, sizeof(name), "vq%02d", i);
>> | ^~~~
>> drivers/vdpa/pds/debugfs.c:269:46: note: directive argument in the range [-2147483641, 254]
>> 269 | snprintf(name, sizeof(name), "vq%02d", i);
>> | ^~~~~~~~
>> drivers/vdpa/pds/debugfs.c:269:17: note: 'snprintf' output between 5 and 14 bytes into a destination of size 8
>> 269 | snprintf(name, sizeof(name), "vq%02d", i);
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>> vim +269 drivers/vdpa/pds/debugfs.c
>
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 259
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 260 void pds_vdpa_debugfs_add_vdpadev(struct pds_vdpa_aux *vdpa_aux)
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 261 {
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 262 int i;
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 263
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 264 debugfs_create_file("config", 0400, vdpa_aux->dentry, vdpa_aux->pdsv, &config_fops);
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 265
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 266 for (i = 0; i < vdpa_aux->pdsv->num_vqs; i++) {
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 267 char name[8];
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 268
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 @269 snprintf(name, sizeof(name), "vq%02d", i);
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 270 debugfs_create_file(name, 0400, vdpa_aux->dentry,
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 271 &vdpa_aux->pdsv->vqs[i], &vq_fops);
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 272 }
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 273 }
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 274
>
>
> So gcc can't figure out that i is positive in this loop :(
>
> Let's make it unsigned I guess? Should calm it down.
>
> Shannon could you send a patch please?
Yes, I've been a little snowed under the last couple of weeks, but will
try to get to this and a couple other similar complaints in the next
week or so.
sln
>
>>
>> :::::: The code at line 269 was first introduced by commit
>> :::::: 151cc834f3ddafec869269fe48036460d920d08a pds_vdpa: add support for vdpa and vdpamgmt interfaces
>>
>> :::::: TO: Shannon Nelson <shannon.nelson@....com>
>> :::::: CC: Michael S. Tsirkin <mst@...hat.com>
>>
>> --
>> 0-DAY CI Kernel Test Service
>> https://github.com/intel/lkp-tests/wiki
>
Powered by blists - more mailing lists