linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
@ 2023-07-24 11:32 kernel test robot
  2023-07-24 14:20 ` Sunil V L
  0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2023-07-24 11:32 UTC (permalink / raw)
  To: Sunil V L
  Cc: oe-kbuild-all, linux-kernel, Palmer Dabbelt, Andrew Jones, Conor Dooley

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   6eaae198076080886b9e7d57f4ae06fa782f90ef
commit: a91a9ffbd3a55a0ae1bb75e2b6e85b2a03f64e8f RISC-V: Add support to build the ACPI core
date:   8 weeks ago
config: riscv-randconfig-r032-20230724 (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-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/202307241942.Rff2Nri5-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/pnp/pnpacpi/core.c: In function 'pnpacpi_add_device.isra':
>> drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size [-Wstringop-truncation]
     253 |                 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +253 drivers/pnp/pnpacpi/core.c

420a0f66378c84 Dmitry Torokhov   2010-09-18  208  
^1da177e4c3f41 Linus Torvalds    2005-04-16  209  static int __init pnpacpi_add_device(struct acpi_device *device)
^1da177e4c3f41 Linus Torvalds    2005-04-16  210  {
^1da177e4c3f41 Linus Torvalds    2005-04-16  211  	struct pnp_dev *dev;
844142c3f80c66 Rasmus Villemoes  2015-09-09  212  	const char *pnpid;
7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  213  	struct acpi_hardware_id *id;
249135d1a2ea3c Dmitry Torokhov   2013-12-15  214  	int error;
^1da177e4c3f41 Linus Torvalds    2005-04-16  215  
2905875344f977 Adrian Hunter     2012-11-23  216  	/* Skip devices that are already bound */
2905875344f977 Adrian Hunter     2012-11-23  217  	if (device->physical_node_count)
2905875344f977 Adrian Hunter     2012-11-23  218  		return 0;
2905875344f977 Adrian Hunter     2012-11-23  219  
39a0ad871000d2 Zhao Yakui        2008-08-11  220  	/*
39a0ad871000d2 Zhao Yakui        2008-08-11  221  	 * If a PnPacpi device is not present , the device
39a0ad871000d2 Zhao Yakui        2008-08-11  222  	 * driver should not be loaded.
39a0ad871000d2 Zhao Yakui        2008-08-11  223  	 */
0e77e2c416e8fa Zhang Rui         2013-09-03  224  	if (!acpi_has_method(device->handle, "_CRS"))
420a0f66378c84 Dmitry Torokhov   2010-09-18  225  		return 0;
420a0f66378c84 Dmitry Torokhov   2010-09-18  226  
420a0f66378c84 Dmitry Torokhov   2010-09-18  227  	pnpid = pnpacpi_get_id(device);
420a0f66378c84 Dmitry Torokhov   2010-09-18  228  	if (!pnpid)
420a0f66378c84 Dmitry Torokhov   2010-09-18  229  		return 0;
420a0f66378c84 Dmitry Torokhov   2010-09-18  230  
eec15edbb0e144 Zhang Rui         2014-05-30  231  	if (!device->status.present)
^1da177e4c3f41 Linus Torvalds    2005-04-16  232  		return 0;
^1da177e4c3f41 Linus Torvalds    2005-04-16  233  
420a0f66378c84 Dmitry Torokhov   2010-09-18  234  	dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
bda1e4e5a3d976 Bjorn Helgaas     2008-04-28  235  	if (!dev)
^1da177e4c3f41 Linus Torvalds    2005-04-16  236  		return -ENOMEM;
bda1e4e5a3d976 Bjorn Helgaas     2008-04-28  237  
2eb1eb02dda368 Rafael J. Wysocki 2015-03-13  238  	ACPI_COMPANION_SET(&dev->dev, device);
c4da6940a7a41c Bjorn Helgaas     2009-11-17  239  	dev->data = device;
07d4e9af109221 Bjorn Helgaas     2007-07-26  240  	/* .enabled means the device can decode the resources */
^1da177e4c3f41 Linus Torvalds    2005-04-16  241  	dev->active = device->status.enabled;
0e77e2c416e8fa Zhang Rui         2013-09-03  242  	if (acpi_has_method(device->handle, "_SRS"))
^1da177e4c3f41 Linus Torvalds    2005-04-16  243  		dev->capabilities |= PNP_CONFIGURABLE;
^1da177e4c3f41 Linus Torvalds    2005-04-16  244  	dev->capabilities |= PNP_READ;
856608ee5e1ea3 Shaohua Li        2008-01-12  245  	if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE))
^1da177e4c3f41 Linus Torvalds    2005-04-16  246  		dev->capabilities |= PNP_WRITE;
^1da177e4c3f41 Linus Torvalds    2005-04-16  247  	if (device->flags.removable)
^1da177e4c3f41 Linus Torvalds    2005-04-16  248  		dev->capabilities |= PNP_REMOVABLE;
0e77e2c416e8fa Zhang Rui         2013-09-03  249  	if (acpi_has_method(device->handle, "_DIS"))
^1da177e4c3f41 Linus Torvalds    2005-04-16  250  		dev->capabilities |= PNP_DISABLE;
^1da177e4c3f41 Linus Torvalds    2005-04-16  251  
^1da177e4c3f41 Linus Torvalds    2005-04-16  252  	if (strlen(acpi_device_name(device)))
^1da177e4c3f41 Linus Torvalds    2005-04-16 @253  		strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
^1da177e4c3f41 Linus Torvalds    2005-04-16  254  	else
^1da177e4c3f41 Linus Torvalds    2005-04-16  255  		strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
^1da177e4c3f41 Linus Torvalds    2005-04-16  256  
d152cf5d0c3325 Bjorn Helgaas     2008-04-28  257  	if (dev->active)
d152cf5d0c3325 Bjorn Helgaas     2008-04-28  258  		pnpacpi_parse_allocated_resource(dev);
^1da177e4c3f41 Linus Torvalds    2005-04-16  259  
d152cf5d0c3325 Bjorn Helgaas     2008-04-28  260  	if (dev->capabilities & PNP_CONFIGURABLE)
d152cf5d0c3325 Bjorn Helgaas     2008-04-28  261  		pnpacpi_parse_resource_option_data(dev);
^1da177e4c3f41 Linus Torvalds    2005-04-16  262  
7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  263  	list_for_each_entry(id, &device->pnp.ids, list) {
420a0f66378c84 Dmitry Torokhov   2010-09-18  264  		if (!strcmp(id->id, pnpid))
^1da177e4c3f41 Linus Torvalds    2005-04-16  265  			continue;
7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  266  		if (!ispnpidacpi(id->id))
7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  267  			continue;
7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  268  		pnp_add_id(dev, id->id);
^1da177e4c3f41 Linus Torvalds    2005-04-16  269  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  270  
^1da177e4c3f41 Linus Torvalds    2005-04-16  271  	/* clear out the damaged flags */
^1da177e4c3f41 Linus Torvalds    2005-04-16  272  	if (!dev->active)
f44900020926b2 Bjorn Helgaas     2008-04-28  273  		pnp_init_resources(dev);
249135d1a2ea3c Dmitry Torokhov   2013-12-15  274  
249135d1a2ea3c Dmitry Torokhov   2013-12-15  275  	error = pnp_add_device(dev);
249135d1a2ea3c Dmitry Torokhov   2013-12-15  276  	if (error) {
249135d1a2ea3c Dmitry Torokhov   2013-12-15  277  		put_device(&dev->dev);
249135d1a2ea3c Dmitry Torokhov   2013-12-15  278  		return error;
249135d1a2ea3c Dmitry Torokhov   2013-12-15  279  	}
249135d1a2ea3c Dmitry Torokhov   2013-12-15  280  
^1da177e4c3f41 Linus Torvalds    2005-04-16  281  	num++;
^1da177e4c3f41 Linus Torvalds    2005-04-16  282  
2eb1eb02dda368 Rafael J. Wysocki 2015-03-13  283  	return 0;
^1da177e4c3f41 Linus Torvalds    2005-04-16  284  }
^1da177e4c3f41 Linus Torvalds    2005-04-16  285  

:::::: The code at line 253 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

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

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

* Re: drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
  2023-07-24 11:32 drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size kernel test robot
@ 2023-07-24 14:20 ` Sunil V L
  2023-07-24 17:15   ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Sunil V L @ 2023-07-24 14:20 UTC (permalink / raw)
  To: kernel test robot
  Cc: oe-kbuild-all, linux-kernel, Palmer Dabbelt, Andrew Jones,
	Conor Dooley, Rafael J. Wysocki

+Rafael.

On Mon, Jul 24, 2023 at 07:32:36PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   6eaae198076080886b9e7d57f4ae06fa782f90ef
> commit: a91a9ffbd3a55a0ae1bb75e2b6e85b2a03f64e8f RISC-V: Add support to build the ACPI core
> date:   8 weeks ago
> config: riscv-randconfig-r032-20230724 (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-lkp@intel.com/config)
> compiler: riscv64-linux-gcc (GCC) 12.3.0
> reproduce: (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-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/202307241942.Rff2Nri5-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/pnp/pnpacpi/core.c: In function 'pnpacpi_add_device.isra':
> >> drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size [-Wstringop-truncation]
>      253 |                 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
>          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
I need some help here to understand what needs to be done. This is a
common code across architectures. Apart from the fact that ACPI is
enabled for the first time for RISC-V, I am unable to understand why
this warning is seen now. Is this because only RISC-V gcc enables this
warning by default? I don't see this with clang tool chain. If this is
expected warning, is there a way to suppress?

Thanks!
Sunil

> 
> vim +/strncpy +253 drivers/pnp/pnpacpi/core.c
> 
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  208  
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  209  static int __init pnpacpi_add_device(struct acpi_device *device)
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  210  {
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  211  	struct pnp_dev *dev;
> 844142c3f80c66 Rasmus Villemoes  2015-09-09  212  	const char *pnpid;
> 7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  213  	struct acpi_hardware_id *id;
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  214  	int error;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  215  
> 2905875344f977 Adrian Hunter     2012-11-23  216  	/* Skip devices that are already bound */
> 2905875344f977 Adrian Hunter     2012-11-23  217  	if (device->physical_node_count)
> 2905875344f977 Adrian Hunter     2012-11-23  218  		return 0;
> 2905875344f977 Adrian Hunter     2012-11-23  219  
> 39a0ad871000d2 Zhao Yakui        2008-08-11  220  	/*
> 39a0ad871000d2 Zhao Yakui        2008-08-11  221  	 * If a PnPacpi device is not present , the device
> 39a0ad871000d2 Zhao Yakui        2008-08-11  222  	 * driver should not be loaded.
> 39a0ad871000d2 Zhao Yakui        2008-08-11  223  	 */
> 0e77e2c416e8fa Zhang Rui         2013-09-03  224  	if (!acpi_has_method(device->handle, "_CRS"))
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  225  		return 0;
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  226  
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  227  	pnpid = pnpacpi_get_id(device);
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  228  	if (!pnpid)
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  229  		return 0;
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  230  
> eec15edbb0e144 Zhang Rui         2014-05-30  231  	if (!device->status.present)
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  232  		return 0;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  233  
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  234  	dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
> bda1e4e5a3d976 Bjorn Helgaas     2008-04-28  235  	if (!dev)
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  236  		return -ENOMEM;
> bda1e4e5a3d976 Bjorn Helgaas     2008-04-28  237  
> 2eb1eb02dda368 Rafael J. Wysocki 2015-03-13  238  	ACPI_COMPANION_SET(&dev->dev, device);
> c4da6940a7a41c Bjorn Helgaas     2009-11-17  239  	dev->data = device;
> 07d4e9af109221 Bjorn Helgaas     2007-07-26  240  	/* .enabled means the device can decode the resources */
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  241  	dev->active = device->status.enabled;
> 0e77e2c416e8fa Zhang Rui         2013-09-03  242  	if (acpi_has_method(device->handle, "_SRS"))
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  243  		dev->capabilities |= PNP_CONFIGURABLE;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  244  	dev->capabilities |= PNP_READ;
> 856608ee5e1ea3 Shaohua Li        2008-01-12  245  	if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE))
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  246  		dev->capabilities |= PNP_WRITE;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  247  	if (device->flags.removable)
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  248  		dev->capabilities |= PNP_REMOVABLE;
> 0e77e2c416e8fa Zhang Rui         2013-09-03  249  	if (acpi_has_method(device->handle, "_DIS"))
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  250  		dev->capabilities |= PNP_DISABLE;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  251  
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  252  	if (strlen(acpi_device_name(device)))
> ^1da177e4c3f41 Linus Torvalds    2005-04-16 @253  		strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  254  	else
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  255  		strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  256  
> d152cf5d0c3325 Bjorn Helgaas     2008-04-28  257  	if (dev->active)
> d152cf5d0c3325 Bjorn Helgaas     2008-04-28  258  		pnpacpi_parse_allocated_resource(dev);
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  259  
> d152cf5d0c3325 Bjorn Helgaas     2008-04-28  260  	if (dev->capabilities & PNP_CONFIGURABLE)
> d152cf5d0c3325 Bjorn Helgaas     2008-04-28  261  		pnpacpi_parse_resource_option_data(dev);
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  262  
> 7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  263  	list_for_each_entry(id, &device->pnp.ids, list) {
> 420a0f66378c84 Dmitry Torokhov   2010-09-18  264  		if (!strcmp(id->id, pnpid))
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  265  			continue;
> 7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  266  		if (!ispnpidacpi(id->id))
> 7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  267  			continue;
> 7f47fa6c2ff15f Bjorn Helgaas     2009-09-21  268  		pnp_add_id(dev, id->id);
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  269  	}
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  270  
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  271  	/* clear out the damaged flags */
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  272  	if (!dev->active)
> f44900020926b2 Bjorn Helgaas     2008-04-28  273  		pnp_init_resources(dev);
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  274  
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  275  	error = pnp_add_device(dev);
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  276  	if (error) {
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  277  		put_device(&dev->dev);
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  278  		return error;
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  279  	}
> 249135d1a2ea3c Dmitry Torokhov   2013-12-15  280  
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  281  	num++;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  282  
> 2eb1eb02dda368 Rafael J. Wysocki 2015-03-13  283  	return 0;
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  284  }
> ^1da177e4c3f41 Linus Torvalds    2005-04-16  285  
> 
> :::::: The code at line 253 was first introduced by commit
> :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
> 
> :::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
> :::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

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

* Re: drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
  2023-07-24 14:20 ` Sunil V L
@ 2023-07-24 17:15   ` Rafael J. Wysocki
  2023-07-25  5:08     ` Sunil V L
  0 siblings, 1 reply; 7+ messages in thread
From: Rafael J. Wysocki @ 2023-07-24 17:15 UTC (permalink / raw)
  To: Sunil V L
  Cc: kernel test robot, oe-kbuild-all, linux-kernel, Palmer Dabbelt,
	Andrew Jones, Conor Dooley, Rafael J. Wysocki

On Mon, Jul 24, 2023 at 4:20 PM Sunil V L <sunilvl@ventanamicro.com> wrote:
>
> +Rafael.
>
> On Mon, Jul 24, 2023 at 07:32:36PM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   6eaae198076080886b9e7d57f4ae06fa782f90ef
> > commit: a91a9ffbd3a55a0ae1bb75e2b6e85b2a03f64e8f RISC-V: Add support to build the ACPI core
> > date:   8 weeks ago
> > config: riscv-randconfig-r032-20230724 (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-lkp@intel.com/config)
> > compiler: riscv64-linux-gcc (GCC) 12.3.0
> > reproduce: (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-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/202307241942.Rff2Nri5-lkp@intel.com/
> >
> > All warnings (new ones prefixed by >>):
> >
> >    drivers/pnp/pnpacpi/core.c: In function 'pnpacpi_add_device.isra':
> > >> drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size [-Wstringop-truncation]
> >      253 |                 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
> >          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> I need some help here to understand what needs to be done. This is a
> common code across architectures. Apart from the fact that ACPI is
> enabled for the first time for RISC-V, I am unable to understand why
> this warning is seen now. Is this because only RISC-V gcc enables this
> warning by default? I don't see this with clang tool chain. If this is
> expected warning, is there a way to suppress?

I think that this is relevant information:

https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice

Thanks!

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

* Re: drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
  2023-07-24 17:15   ` Rafael J. Wysocki
@ 2023-07-25  5:08     ` Sunil V L
  2023-07-25  8:51       ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Sunil V L @ 2023-07-25  5:08 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: kernel test robot, oe-kbuild-all, linux-kernel, Palmer Dabbelt,
	Andrew Jones, Conor Dooley

On Mon, Jul 24, 2023 at 07:15:22PM +0200, Rafael J. Wysocki wrote:
> On Mon, Jul 24, 2023 at 4:20 PM Sunil V L <sunilvl@ventanamicro.com> wrote:
> >
> > +Rafael.
> >
> > On Mon, Jul 24, 2023 at 07:32:36PM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   6eaae198076080886b9e7d57f4ae06fa782f90ef
> > > commit: a91a9ffbd3a55a0ae1bb75e2b6e85b2a03f64e8f RISC-V: Add support to build the ACPI core
> > > date:   8 weeks ago
> > > config: riscv-randconfig-r032-20230724 (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-lkp@intel.com/config)
> > > compiler: riscv64-linux-gcc (GCC) 12.3.0
> > > reproduce: (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-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/202307241942.Rff2Nri5-lkp@intel.com/
> > >
> > > All warnings (new ones prefixed by >>):
> > >
> > >    drivers/pnp/pnpacpi/core.c: In function 'pnpacpi_add_device.isra':
> > > >> drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size [-Wstringop-truncation]
> > >      253 |                 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
> > >          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >
> > I need some help here to understand what needs to be done. This is a
> > common code across architectures. Apart from the fact that ACPI is
> > enabled for the first time for RISC-V, I am unable to understand why
> > this warning is seen now. Is this because only RISC-V gcc enables this
> > warning by default? I don't see this with clang tool chain. If this is
> > expected warning, is there a way to suppress?
> 
> I think that this is relevant information:
> 
> https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice
> 
Thank you very much! Rafael. Let me send a patch to append a NUL
explicitly to fix this issue. However, I still wonder why this code
added in 2005 getting this warning only now. Why is this not being seen
with other architecture builds?

Thanks!
Sunil

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

* Re: drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
  2023-07-25  5:08     ` Sunil V L
@ 2023-07-25  8:51       ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2023-07-25  8:51 UTC (permalink / raw)
  To: Sunil V L
  Cc: Rafael J. Wysocki, kernel test robot, oe-kbuild-all,
	linux-kernel, Palmer Dabbelt, Andrew Jones, Conor Dooley

On Tue, Jul 25, 2023 at 7:08 AM Sunil V L <sunilvl@ventanamicro.com> wrote:
>
> On Mon, Jul 24, 2023 at 07:15:22PM +0200, Rafael J. Wysocki wrote:
> > On Mon, Jul 24, 2023 at 4:20 PM Sunil V L <sunilvl@ventanamicro.com> wrote:
> > >
> > > +Rafael.
> > >
> > > On Mon, Jul 24, 2023 at 07:32:36PM +0800, kernel test robot wrote:
> > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > > head:   6eaae198076080886b9e7d57f4ae06fa782f90ef
> > > > commit: a91a9ffbd3a55a0ae1bb75e2b6e85b2a03f64e8f RISC-V: Add support to build the ACPI core
> > > > date:   8 weeks ago
> > > > config: riscv-randconfig-r032-20230724 (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-lkp@intel.com/config)
> > > > compiler: riscv64-linux-gcc (GCC) 12.3.0
> > > > reproduce: (https://download.01.org/0day-ci/archive/20230724/202307241942.Rff2Nri5-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/202307241942.Rff2Nri5-lkp@intel.com/
> > > >
> > > > All warnings (new ones prefixed by >>):
> > > >
> > > >    drivers/pnp/pnpacpi/core.c: In function 'pnpacpi_add_device.isra':
> > > > >> drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size [-Wstringop-truncation]
> > > >      253 |                 strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
> > > >          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >
> > > I need some help here to understand what needs to be done. This is a
> > > common code across architectures. Apart from the fact that ACPI is
> > > enabled for the first time for RISC-V, I am unable to understand why
> > > this warning is seen now. Is this because only RISC-V gcc enables this
> > > warning by default? I don't see this with clang tool chain. If this is
> > > expected warning, is there a way to suppress?
> >
> > I think that this is relevant information:
> >
> > https://stackoverflow.com/questions/50198319/gcc-8-wstringop-truncation-what-is-the-good-practice
> >
> Thank you very much! Rafael. Let me send a patch to append a NUL
> explicitly to fix this issue. However, I still wonder why this code
> added in 2005 getting this warning only now. Why is this not being seen
> with other architecture builds?

I don't know.

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

* Re: drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
  2023-07-26 14:05 ` drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size Suzuki K Poulose
@ 2023-07-26 14:58   ` Sudeep Holla
  0 siblings, 0 replies; 7+ messages in thread
From: Sudeep Holla @ 2023-07-26 14:58 UTC (permalink / raw)
  To: Suzuki K Poulose, rafael
  Cc: gregkh, Sudeep Holla, linux-arm-kernel, linux-kernel, coresight,
	scclevenger, leo.yan, linux-acpi, mike.leach

On Wed, Jul 26, 2023 at 03:05:15PM +0100, Suzuki K Poulose wrote:
> On 25/07/2023 15:30, Rafael J. Wysocki wrote:
> > On Tue, Jul 25, 2023 at 4:040x202FPM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>
> >> On 25/07/2023 15:00, Rafael J. Wysocki wrote:
> >>> On Tue, Jul 25, 2023 at 3:270x202FPM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
> >>>>
> >>>> On 25/07/2023 13:28, Rafael J. Wysocki wrote:
> >>>>> On Tue, Jul 25, 2023 at 12:350x202FPM Suzuki K Poulose
> >>>>> <suzuki.poulose@arm.com> wrote:
> >>>>>>
> >>>>>> Hi Rafael
> >>>>>>
> >>>>>> Apologies for hijacking this thread, but please please could
> >>>>>> you respond to the following patch ?
> >>>>>>
> >>>>>> We have been waiting for your Ack since last two months.
> >>>>>>
> >>>>>> https://lkml.kernel.org/r/46a3d6d3-f14e-efde-83eb-5952f313f909@arm.com
> >>>>>
> >>>>> Sorry about that, but I'm not sure why you need an ACK from me for
> >>>>> this.0x00A0 AMBA is an ARM thing and I'm not even familiar with the driver
> >>>>> in question.
> >>>>>
> >>>>
> >>>> I understand, but there is a change to the drivers/acpi/acpi_amba.c ,
> >>>> which is technically under your maintenance. The change is removing
> >>>> the custom hook for the ETMv4 ID from the AMBA list and moving it
> >>>> directly under the ETMv4 driver. Greg would like an Ack from you
> >>>> before that can be queued. It missed the merged window last time
> >>>> due to that and didn't want to miss it again this time.
> >>>
> >>> OK, so please feel free to add an ACK from me to that patch.
> >>>
> >>
> >> Thanks.
> >>
> >>> It also would be good to find an ARM maintainer for acpi_amba.c, so
> >>> people don't have to wait for my ACK on every change in that file.
> >>
> >> Sudeep Holla (our resident ACPI expert) has reviewed the patch, but
> >> I guess he is in the Reviewer ranks.
> >
> > Well, next time you get a Reviewed-by from Sudeep on ARM-related ACPI
> > material, it is far more meaningful than my ACK.0x00A0 You probably don't
> > need the latter if you have the former.

Thanks Rafael and this aligns with my understanding. I had mentioned to
Suzuki informally. Since I wasn't sure why this was not covered under
Arm ACPI maintainership for whatever historical reasons, I didn't make
it formally on the list. I think it would be better if we move that file
under it to be explicit and avoid any confusion in the future. I will
send the update soon.

-- 
Regards,
Sudeep

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

* Re: drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size
  2023-07-10  6:25 [PATCH V6 6/6] coresight: etm4x: Add ACPI support in platform driver Anshuman Khandual
@ 2023-07-26 14:05 ` Suzuki K Poulose
  2023-07-26 14:58   ` Sudeep Holla
  0 siblings, 1 reply; 7+ messages in thread
From: Suzuki K Poulose @ 2023-07-26 14:05 UTC (permalink / raw)
  To: rafael
  Cc: gregkh, linux-arm-kernel, linux-kernel, coresight, sudeep.holla,
	scclevenger, leo.yan, linux-acpi, mike.leach, suzuki.poulose

On 25/07/2023 15:30, Rafael J. Wysocki wrote:
> On Tue, Jul 25, 2023 at 4:040x202FPM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>
>> On 25/07/2023 15:00, Rafael J. Wysocki wrote:
>>> On Tue, Jul 25, 2023 at 3:270x202FPM Suzuki K Poulose <suzuki.poulose@arm.com> wrote:
>>>>
>>>> On 25/07/2023 13:28, Rafael J. Wysocki wrote:
>>>>> On Tue, Jul 25, 2023 at 12:350x202FPM Suzuki K Poulose
>>>>> <suzuki.poulose@arm.com> wrote:
>>>>>>
>>>>>> Hi Rafael
>>>>>>
>>>>>> Apologies for hijacking this thread, but please please could
>>>>>> you respond to the following patch ?
>>>>>>
>>>>>> We have been waiting for your Ack since last two months.
>>>>>>
>>>>>> https://lkml.kernel.org/r/46a3d6d3-f14e-efde-83eb-5952f313f909@arm.com
>>>>>
>>>>> Sorry about that, but I'm not sure why you need an ACK from me for
>>>>> this.0x00A0 AMBA is an ARM thing and I'm not even familiar with the driver
>>>>> in question.
>>>>>
>>>>
>>>> I understand, but there is a change to the drivers/acpi/acpi_amba.c ,
>>>> which is technically under your maintenance. The change is removing
>>>> the custom hook for the ETMv4 ID from the AMBA list and moving it
>>>> directly under the ETMv4 driver. Greg would like an Ack from you
>>>> before that can be queued. It missed the merged window last time
>>>> due to that and didn't want to miss it again this time.
>>>
>>> OK, so please feel free to add an ACK from me to that patch.
>>>
>>
>> Thanks.
>>
>>> It also would be good to find an ARM maintainer for acpi_amba.c, so
>>> people don't have to wait for my ACK on every change in that file.
>>
>> Sudeep Holla (our resident ACPI expert) has reviewed the patch, but
>> I guess he is in the Reviewer ranks.
>
> Well, next time you get a Reviewed-by from Sudeep on ARM-related ACPI
> material, it is far more meaningful than my ACK.0x00A0 You probably don't
> need the latter if you have the former.

Thanks Rafael.

For others wondering about the weird threading, the above happened via private
exchange of emails and linking to this patch for the record.


Suzuki

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

end of thread, other threads:[~2023-07-26 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 11:32 drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size kernel test robot
2023-07-24 14:20 ` Sunil V L
2023-07-24 17:15   ` Rafael J. Wysocki
2023-07-25  5:08     ` Sunil V L
2023-07-25  8:51       ` Rafael J. Wysocki
  -- strict thread matches above, loose matches on Subject: below --
2023-07-10  6:25 [PATCH V6 6/6] coresight: etm4x: Add ACPI support in platform driver Anshuman Khandual
2023-07-26 14:05 ` drivers/pnp/pnpacpi/core.c:253:17: warning: 'strncpy' specified bound 50 equals destination size Suzuki K Poulose
2023-07-26 14:58   ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).