All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: kernel test robot <lkp@intel.com>
Cc: Shannon Nelson <shannon.nelson@amd.com>,
	oe-kbuild-all@lists.linux.dev, linux-kernel@vger.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
Date: Sun, 5 Nov 2023 07:57:44 -0500	[thread overview]
Message-ID: <20231105075350-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <202311040109.RfgJoE7L-lkp@intel.com>

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


  reply	other threads:[~2023-11-05 12:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-11-06  5:19   ` Nelson, Shannon

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=20231105075350-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=shannon.nelson@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.