Skip to contentSkip to conversation

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

DISCUSSION kernel test robot 3 participants 3 messages Nov 3, 2023 – Nov 6, 2023

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
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/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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 <[email protected]> :::::: CC: Michael S. Tsirkin <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#1 lore raw
Quoted 44 lines · kernel test robot
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/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/vdpa/pds/debugfs.c: In function 'pds_vdpa_debugfs_add_vdpadev':

Quoted 1 line
Quoted 1 line

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  }
Quoted 1 line

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?

Quoted 10 lines

:::::: The code at line 269 was first introduced by commit
:::::: 151cc834f3ddafec869269fe48036460d920d08a pds_vdpa: add support for vdpa and vdpamgmt interfaces

:::::: TO: Shannon Nelson <[email protected]> :::::: CC: Michael S. Tsirkin <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
Quoted 51 lines · Michael S. Tsirkin

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 29 lines · kernel test robot
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/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/vdpa/pds/debugfs.c: In function 'pds_vdpa_debugfs_add_vdpadev':

Quoted 1 line
Quoted 1 line

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

Quoted 16 lines
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
Quoted 5 lines

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

Quoted 12 lines
Quoted 11 lines

:::::: The code at line 269 was first introduced by commit
:::::: 151cc834f3ddafec869269fe48036460d920d08a pds_vdpa: add support for vdpa and vdpamgmt interfaces

:::::: TO: Shannon Nelson <[email protected]> :::::: CC: Michael S. Tsirkin <[email protected]>

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