public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* 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
@ 2023-11-03 17:36 kernel test robot
  2023-11-05 12:57 ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2023-11-03 17:36 UTC (permalink / raw)
  To: Shannon Nelson; +Cc: oe-kbuild-all, linux-kernel, Michael S. Tsirkin

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@intel.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  

:::::: 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@amd.com>
:::::: CC: Michael S. Tsirkin <mst@redhat.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* 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
  2023-11-03 17:36 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 kernel test robot
@ 2023-11-05 12:57 ` Michael S. Tsirkin
  2023-11-06  5:19   ` Nelson, Shannon
  0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2023-11-05 12:57 UTC (permalink / raw)
  To: kernel test robot; +Cc: Shannon Nelson, oe-kbuild-all, linux-kernel

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@intel.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?

> 
> :::::: 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@amd.com>
> :::::: CC: Michael S. Tsirkin <mst@redhat.com>
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 3+ messages in thread

* 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
  2023-11-05 12:57 ` Michael S. Tsirkin
@ 2023-11-06  5:19   ` Nelson, Shannon
  0 siblings, 0 replies; 3+ messages in thread
From: Nelson, Shannon @ 2023-11-06  5:19 UTC (permalink / raw)
  To: Michael S. Tsirkin, kernel test robot; +Cc: oe-kbuild-all, linux-kernel

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@intel.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@amd.com>
>> :::::: CC: Michael S. Tsirkin <mst@redhat.com>
>>
>> --
>> 0-DAY CI Kernel Test Service
>> https://github.com/intel/lkp-tests/wiki
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-06  5:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-03 17:36 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 kernel test robot
2023-11-05 12:57 ` Michael S. Tsirkin
2023-11-06  5:19   ` Nelson, Shannon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox