public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
@ 2023-11-06 10:41 kernel test robot
  2023-11-08  6:13 ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: kernel test robot @ 2023-11-06 10:41 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: oe-kbuild-all, linux-kernel

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   d2f51b3516dade79269ff45eae2a7668ae711b25
commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
date:   4 years, 11 months ago
config: x86_64-randconfig-r025-20230725 (https://download.01.org/0day-ci/archive/20231106/202311061847.BOtfUmbQ-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231106/202311061847.BOtfUmbQ-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/202311061847.BOtfUmbQ-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/opp/debugfs.c: In function 'opp_debug_create_one':
>> drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                                                      ^~
   In function 'opp_debug_create_supplies',
       inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:119:7:
   drivers/opp/debugfs.c:48:46: note: directive argument in the range [-2147483644, 2147483646]
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                                              ^~~~~~~~~~~
   drivers/opp/debugfs.c:48:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +48 drivers/opp/debugfs.c

deaa51465105a7 drivers/base/power/opp/debugfs.c Viresh Kumar 2015-11-11  37  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  38  static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  39  				      struct opp_table *opp_table,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  40  				      struct dentry *pdentry)
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  41  {
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  42  	struct dentry *d;
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  43  	int i;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  44  
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  45  	for (i = 0; i < opp_table->regulator_count; i++) {
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21  46  		char name[15];
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21  47  
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21 @48  		snprintf(name, sizeof(name), "supply-%d", i);
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  49  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  50  		/* Create per-opp directory */
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  51  		d = debugfs_create_dir(name, pdentry);
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  52  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  53  		if (!d)
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  54  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  55  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  56  		if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  57  					  &opp->supplies[i].u_volt))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  58  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  59  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  60  		if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  61  					  &opp->supplies[i].u_volt_min))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  62  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  63  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  64  		if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  65  					  &opp->supplies[i].u_volt_max))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  66  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  67  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  68  		if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  69  					  &opp->supplies[i].u_amp))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  70  			return false;
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  71  	}
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  72  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  73  	return true;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  74  }
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  75  

:::::: The code at line 48 was first introduced by commit
:::::: d741029a2390406d4d94279ae5b346831a9e61e6 PM / OPP: Use snprintf() to avoid kasprintf() and kfree()

:::::: TO: Arvind Yadav <arvind.yadav.cs@gmail.com>
:::::: CC: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2023-11-06 10:41 drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 kernel test robot
@ 2023-11-08  6:13 ` Viresh Kumar
  0 siblings, 0 replies; 12+ messages in thread
From: Viresh Kumar @ 2023-11-08  6:13 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel

On 06-11-23, 18:41, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   d2f51b3516dade79269ff45eae2a7668ae711b25
> commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
> date:   4 years, 11 months ago

This is a really old commit, are we running the test over it ? Or it is what git
bisect reported ?

> config: x86_64-randconfig-r025-20230725 (https://download.01.org/0day-ci/archive/20231106/202311061847.BOtfUmbQ-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231106/202311061847.BOtfUmbQ-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/202311061847.BOtfUmbQ-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/opp/debugfs.c: In function 'opp_debug_create_one':
> >> drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
>       48 |                 snprintf(name, sizeof(name), "supply-%d", i);
>          |                                                      ^~
>    In function 'opp_debug_create_supplies',
>        inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:119:7:
>    drivers/opp/debugfs.c:48:46: note: directive argument in the range [-2147483644, 2147483646]
>       48 |                 snprintf(name, sizeof(name), "supply-%d", i);
>          |                                              ^~~~~~~~~~~
>    drivers/opp/debugfs.c:48:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
>       48 |                 snprintf(name, sizeof(name), "supply-%d", i);
>          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I tried to reproduce it for ARM and don't see the warning locally. I saw a
similar one earlier (reported by the bot), which is already fixed:

make ARCH=arm64 O=../barm64/ -j8 CROSS_COMPILE=aarch64-linux-gnu- W=1 CONFIG_DEBUG_SECTION_MISMATCH=y

-- 
viresh

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

* drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
@ 2023-12-16 22:23 kernel test robot
  2023-12-18  6:10 ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: kernel test robot @ 2023-12-16 22:23 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: oe-kbuild-all, linux-kernel

Hi Viresh,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   3b8a9b2e6809d281890dd0a1102dc14d2cd11caf
commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
date:   5 years ago
config: x86_64-randconfig-a006-20230623 (https://download.01.org/0day-ci/archive/20231217/202312170608.s9xI4TQb-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231217/202312170608.s9xI4TQb-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/202312170608.s9xI4TQb-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/opp/debugfs.c: In function 'opp_debug_create_one':
>> drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                                                      ^~
   In function 'opp_debug_create_supplies',
       inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:119:7:
   drivers/opp/debugfs.c:48:46: note: directive argument in the range [-2147483644, 2147483646]
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                                              ^~~~~~~~~~~
   drivers/opp/debugfs.c:48:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +48 drivers/opp/debugfs.c

deaa51465105a7 drivers/base/power/opp/debugfs.c Viresh Kumar 2015-11-11  37  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  38  static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  39  				      struct opp_table *opp_table,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  40  				      struct dentry *pdentry)
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  41  {
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  42  	struct dentry *d;
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  43  	int i;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  44  
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  45  	for (i = 0; i < opp_table->regulator_count; i++) {
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21  46  		char name[15];
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21  47  
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21 @48  		snprintf(name, sizeof(name), "supply-%d", i);
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  49  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  50  		/* Create per-opp directory */
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  51  		d = debugfs_create_dir(name, pdentry);
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  52  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  53  		if (!d)
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  54  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  55  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  56  		if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  57  					  &opp->supplies[i].u_volt))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  58  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  59  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  60  		if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  61  					  &opp->supplies[i].u_volt_min))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  62  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  63  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  64  		if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  65  					  &opp->supplies[i].u_volt_max))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  66  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  67  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  68  		if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  69  					  &opp->supplies[i].u_amp))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  70  			return false;
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  71  	}
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  72  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  73  	return true;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  74  }
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  75  

:::::: The code at line 48 was first introduced by commit
:::::: d741029a2390406d4d94279ae5b346831a9e61e6 PM / OPP: Use snprintf() to avoid kasprintf() and kfree()

:::::: TO: Arvind Yadav <arvind.yadav.cs@gmail.com>
:::::: CC: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2023-12-16 22:23 kernel test robot
@ 2023-12-18  6:10 ` Viresh Kumar
  0 siblings, 0 replies; 12+ messages in thread
From: Viresh Kumar @ 2023-12-18  6:10 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel

On 17-12-23, 06:23, kernel test robot wrote:
> Hi Viresh,
> 
> FYI, the error/warning still remains.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   3b8a9b2e6809d281890dd0a1102dc14d2cd11caf
> commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
> date:   5 years ago
> config: x86_64-randconfig-a006-20230623 (https://download.01.org/0day-ci/archive/20231217/202312170608.s9xI4TQb-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231217/202312170608.s9xI4TQb-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/202312170608.s9xI4TQb-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    drivers/opp/debugfs.c: In function 'opp_debug_create_one':
> >> drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
>       48 |                 snprintf(name, sizeof(name), "supply-%d", i);
>          |                                                      ^~
>    In function 'opp_debug_create_supplies',
>        inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:119:7:
>    drivers/opp/debugfs.c:48:46: note: directive argument in the range [-2147483644, 2147483646]
>       48 |                 snprintf(name, sizeof(name), "supply-%d", i);
>          |                                              ^~~~~~~~~~~
>    drivers/opp/debugfs.c:48:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
>       48 |                 snprintf(name, sizeof(name), "supply-%d", i);
>          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Can someone check if this happens on mainline too ? I think this is a
False report.

-- 
viresh

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

* drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
@ 2024-02-14  5:43 kernel test robot
  2024-02-14  5:58 ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: kernel test robot @ 2024-02-14  5:43 UTC (permalink / raw)
  To: Viresh Kumar; +Cc: oe-kbuild-all, linux-kernel

Hi Viresh,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7e90b5c295ec1e47c8ad865429f046970c549a66
commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
date:   5 years ago
config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-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/202402141313.81ltVF5g-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/opp/debugfs.c: In function 'opp_debug_create_one':
>> drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                                                      ^~
   In function 'opp_debug_create_supplies',
       inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:119:7:
   drivers/opp/debugfs.c:48:46: note: directive argument in the range [-2147483644, 2147483646]
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                                              ^~~~~~~~~~~
   drivers/opp/debugfs.c:48:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
      48 |                 snprintf(name, sizeof(name), "supply-%d", i);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +48 drivers/opp/debugfs.c

deaa51465105a7 drivers/base/power/opp/debugfs.c Viresh Kumar 2015-11-11  37  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  38  static bool opp_debug_create_supplies(struct dev_pm_opp *opp,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  39  				      struct opp_table *opp_table,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  40  				      struct dentry *pdentry)
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  41  {
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  42  	struct dentry *d;
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  43  	int i;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  44  
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  45  	for (i = 0; i < opp_table->regulator_count; i++) {
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21  46  		char name[15];
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21  47  
d741029a239040 drivers/opp/debugfs.c            Arvind Yadav 2017-09-21 @48  		snprintf(name, sizeof(name), "supply-%d", i);
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  49  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  50  		/* Create per-opp directory */
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  51  		d = debugfs_create_dir(name, pdentry);
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  52  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  53  		if (!d)
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  54  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  55  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  56  		if (!debugfs_create_ulong("u_volt_target", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  57  					  &opp->supplies[i].u_volt))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  58  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  59  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  60  		if (!debugfs_create_ulong("u_volt_min", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  61  					  &opp->supplies[i].u_volt_min))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  62  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  63  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  64  		if (!debugfs_create_ulong("u_volt_max", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  65  					  &opp->supplies[i].u_volt_max))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  66  			return false;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  67  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  68  		if (!debugfs_create_ulong("u_amp", S_IRUGO, d,
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  69  					  &opp->supplies[i].u_amp))
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  70  			return false;
1fae788ed640e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2017-05-23  71  	}
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  72  
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  73  	return true;
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  74  }
dfbe4678d709e2 drivers/base/power/opp/debugfs.c Viresh Kumar 2016-12-01  75  

:::::: The code at line 48 was first introduced by commit
:::::: d741029a2390406d4d94279ae5b346831a9e61e6 PM / OPP: Use snprintf() to avoid kasprintf() and kfree()

:::::: TO: Arvind Yadav <arvind.yadav.cs@gmail.com>
:::::: CC: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

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

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-02-14  5:43 kernel test robot
@ 2024-02-14  5:58 ` Viresh Kumar
  2024-02-21  6:01   ` Liu, Yujie
  0 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2024-02-14  5:58 UTC (permalink / raw)
  To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel

On 14-02-24, 13:43, kernel test robot wrote:
> Hi Viresh,
> 
> FYI, the error/warning still remains.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   7e90b5c295ec1e47c8ad865429f046970c549a66
> commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
> date:   5 years ago
> config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-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/202402141313.81ltVF5g-lkp@intel.com/

I have informed this earlier too, this report is incorrect and applies
to a very old commit.

-- 
viresh

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-02-14  5:58 ` Viresh Kumar
@ 2024-02-21  6:01   ` Liu, Yujie
  2024-03-04  6:54     ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: Liu, Yujie @ 2024-02-21  6:01 UTC (permalink / raw)
  To: viresh.kumar@linaro.org, lkp
  Cc: linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev

Hi Viresh,

On Wed, 2024-02-14 at 11:28 +0530, Viresh Kumar wrote:
> On 14-02-24, 13:43, kernel test robot wrote:
> > Hi Viresh,
> > 
> > FYI, the error/warning still remains.
> > 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   7e90b5c295ec1e47c8ad865429f046970c549a66
> > commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
> > date:   5 years ago
> > config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-lkp@intel.com/config)
> > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-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/202402141313.81ltVF5g-lkp@intel.com/
> 
> I have informed this earlier too, this report is incorrect and applies
> to a very old commit.

Really sorry for not responding timely to the questions in the
following reports:

[1] https://lore.kernel.org/all/202311061847.BOtfUmbQ-lkp@intel.com/
[2] https://lore.kernel.org/all/202312170608.s9xI4TQb-lkp@intel.com/

We see that this still happens on the latest mainline rc regardless of
x86_64 or arm64 arch. Please note that this is a "W=1" warning. In our
tests, it can be reproduced with gcc-12 and gcc-13, but not with other
versions of gcc.

$ git checkout v6.8-rc5 
HEAD is now at b401b621758e4 Linux 6.8-rc5

$ wget https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-lkp@intel.com/config -O .config

$ make CC=gcc-12 W=1 -j72 ARCH=x86_64 olddefconfig
$ make CC=gcc-12 W=1 -j72 ARCH=x86_64 drivers/opp/debugfs.o
...
drivers/opp/debugfs.c: In function 'opp_debug_create_one':
drivers/opp/debugfs.c:105:54: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  105 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                                                      ^~
In function 'opp_debug_create_supplies',
    inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:163:2:
drivers/opp/debugfs.c:105:46: note: directive argument in the range [-2147483644, 2147483646]
  105 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                                              ^~~~~~~~~~~
drivers/opp/debugfs.c:105:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
  105 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ make CROSS_COMPILE=aarch64-linux-gnu- CC=aarch64-linux-gnu-gcc-12 W=1 -j72 ARCH=arm64 olddefconfig
$ make CROSS_COMPILE=aarch64-linux-gnu- CC=aarch64-linux-gnu-gcc-12 W=1 -j72 ARCH=arm64 drivers/opp/debugfs.o
...
drivers/opp/debugfs.c: In function 'opp_debug_create_one':
drivers/opp/debugfs.c:105:54: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Werror=format-truncation=]
  105 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                                                      ^~
In function 'opp_debug_create_supplies',
    inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:163:2:
drivers/opp/debugfs.c:105:46: note: directive argument in the range [-2147483644, 2147483646]
  105 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                                              ^~~~~~~~~~~
drivers/opp/debugfs.c:105:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 15
  105 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We are not sure if this is a real problem or a compiler shortcoming
that gcc calculates an incorrect size. Might need gcc experts to take a
look.

Regardless, we will configure the bot to ignore this issue to avoid
further bothering you with duplicate reports.

Best Regards,
Yujie

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-02-21  6:01   ` Liu, Yujie
@ 2024-03-04  6:54     ` Viresh Kumar
  2024-03-04  8:30       ` Yujie Liu
  0 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2024-03-04  6:54 UTC (permalink / raw)
  To: Liu, Yujie
  Cc: lkp, linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev

On 21-02-24, 06:01, Liu, Yujie wrote:
> Hi Viresh,
> 
> On Wed, 2024-02-14 at 11:28 +0530, Viresh Kumar wrote:
> > On 14-02-24, 13:43, kernel test robot wrote:
> > > Hi Viresh,
> > > 
> > > FYI, the error/warning still remains.
> > > 
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > head:   7e90b5c295ec1e47c8ad865429f046970c549a66
> > > commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
> > > date:   5 years ago
> > > config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-lkp@intel.com/config)
> > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-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/202402141313.81ltVF5g-lkp@intel.com/
> > 
> > I have informed this earlier too, this report is incorrect and applies
> > to a very old commit.
> 
> Really sorry for not responding timely to the questions in the
> following reports:
> 
> [1] https://lore.kernel.org/all/202311061847.BOtfUmbQ-lkp@intel.com/
> [2] https://lore.kernel.org/all/202312170608.s9xI4TQb-lkp@intel.com/
> 
> We see that this still happens on the latest mainline rc regardless of
> x86_64 or arm64 arch. Please note that this is a "W=1" warning. In our
> tests, it can be reproduced with gcc-12 and gcc-13, but not with other
> versions of gcc.

Okay, I have a different version of gcc. Can you see if this change fixes it or
not ?

diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index ec030b19164a..986c08e18d05 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -100,7 +100,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
        int i;

        for (i = 0; i < opp_table->regulator_count; i++) {
-               char name[15];
+               char name[19];

                snprintf(name, sizeof(name), "supply-%d", i);

-- 
viresh

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-03-04  6:54     ` Viresh Kumar
@ 2024-03-04  8:30       ` Yujie Liu
  2024-03-04 11:21         ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: Yujie Liu @ 2024-03-04  8:30 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: lkp, linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev

On Mon, Mar 04, 2024 at 12:24:11PM +0530, Viresh Kumar wrote:
> On 21-02-24, 06:01, Liu, Yujie wrote:
> > Hi Viresh,
> > 
> > On Wed, 2024-02-14 at 11:28 +0530, Viresh Kumar wrote:
> > > On 14-02-24, 13:43, kernel test robot wrote:
> > > > Hi Viresh,
> > > > 
> > > > FYI, the error/warning still remains.
> > > > 
> > > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > > > head:   7e90b5c295ec1e47c8ad865429f046970c549a66
> > > > commit: 46f48aca2e5aef3f430e95d1a5fb68227ec8ec85 OPP: Fix missing debugfs supply directory for OPPs
> > > > date:   5 years ago
> > > > config: x86_64-buildonly-randconfig-001-20231012 (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-lkp@intel.com/config)
> > > > compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> > > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/202402141313.81ltVF5g-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/202402141313.81ltVF5g-lkp@intel.com/
> > > 
> > > I have informed this earlier too, this report is incorrect and applies
> > > to a very old commit.
> > 
> > Really sorry for not responding timely to the questions in the
> > following reports:
> > 
> > [1] https://lore.kernel.org/all/202311061847.BOtfUmbQ-lkp@intel.com/
> > [2] https://lore.kernel.org/all/202312170608.s9xI4TQb-lkp@intel.com/
> > 
> > We see that this still happens on the latest mainline rc regardless of
> > x86_64 or arm64 arch. Please note that this is a "W=1" warning. In our
> > tests, it can be reproduced with gcc-12 and gcc-13, but not with other
> > versions of gcc.
> 
> Okay, I have a different version of gcc. Can you see if this change fixes it or
> not ?

This fixes the warning for "supply-%d". Seems there are other remaining
warnings as shown below. Would you like to take a look as well?

  CC      drivers/opp/debugfs.o
drivers/opp/debugfs.c: In function 'bw_name_read':
drivers/opp/debugfs.c:43:42: error: '%.62s' directive argument is null [-Werror=format-overflow=]
   43 |         i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
      |                                          ^~~~~
drivers/opp/debugfs.c: In function 'opp_debug_create_one':
drivers/opp/debugfs.c:90:55: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 4 [-Werror=format-truncation=]
   90 |                 snprintf(name, sizeof(name), "rate_hz_%d", i);
      |                                                       ^~
In function 'opp_debug_create_clks',
    inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:162:2:
drivers/opp/debugfs.c:90:46: note: directive argument in the range [-2147483644, 2147483646]
   90 |                 snprintf(name, sizeof(name), "rate_hz_%d", i);
      |                                              ^~~~~~~~~~~~
drivers/opp/debugfs.c:90:17: note: 'snprintf' output between 10 and 20 bytes into a destination of size 12
   90 |                 snprintf(name, sizeof(name), "rate_hz_%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Best Regards,
Yujie

> 
> diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
> index ec030b19164a..986c08e18d05 100644
> --- a/drivers/opp/debugfs.c
> +++ b/drivers/opp/debugfs.c
> @@ -100,7 +100,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
>         int i;
> 
>         for (i = 0; i < opp_table->regulator_count; i++) {
> -               char name[15];
> +               char name[19];
> 
>                 snprintf(name, sizeof(name), "supply-%d", i);
> 
> -- 
> viresh

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-03-04  8:30       ` Yujie Liu
@ 2024-03-04 11:21         ` Viresh Kumar
  2024-03-05  5:37           ` Yujie Liu
  0 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2024-03-04 11:21 UTC (permalink / raw)
  To: Yujie Liu
  Cc: lkp, linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev

On 04-03-24, 16:30, Yujie Liu wrote:
> This fixes the warning for "supply-%d". Seems there are other remaining
> warnings as shown below. Would you like to take a look as well?

How about this instead to fix all warnings (drop the earlier change
please) ?

diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index ec030b19164a..a9ebfdf0b6a1 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -37,10 +37,12 @@ static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
                            size_t count, loff_t *ppos)
 {
        struct icc_path *path = fp->private_data;
+       const char *name = icc_get_name(path);
        char buf[64];
-       int i;
+       int i = 0;

-       i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
+       if (name)
+               i = scnprintf(buf, sizeof(buf), "%.62s\n", name);

        return simple_read_from_buffer(userbuf, count, ppos, buf, i);
 }
@@ -56,11 +58,11 @@ static void opp_debug_create_bw(struct dev_pm_opp *opp,
                                struct dentry *pdentry)
 {
        struct dentry *d;
-       char name[20];
+       char name[] = "icc-path-XXXXXXXXXX"; /* Integers can take 10 chars max */
        int i;

        for (i = 0; i < opp_table->path_count; i++) {
-               snprintf(name, sizeof(name), "icc-path-%.1d", i);
+               snprintf(name, sizeof(name), "icc-path-%d", i);

                /* Create per-path directory */
                d = debugfs_create_dir(name, pdentry);
@@ -78,7 +80,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp,
                                  struct opp_table *opp_table,
                                  struct dentry *pdentry)
 {
-       char name[12];
+       char name[] = "rate_hz_XXXXXXXXXX"; /* Integers can take 10 chars max */
        int i;

        if (opp_table->clk_count == 1) {
@@ -100,7 +102,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
        int i;

        for (i = 0; i < opp_table->regulator_count; i++) {
-               char name[15];
+               char name[] = "supply-XXXXXXXXXX"; /* Integers can take 10 chars max */

                snprintf(name, sizeof(name), "supply-%d", i);

-- 
viresh

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-03-04 11:21         ` Viresh Kumar
@ 2024-03-05  5:37           ` Yujie Liu
  2024-03-05  6:10             ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: Yujie Liu @ 2024-03-05  5:37 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: lkp, linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev

On Mon, Mar 04, 2024 at 04:51:02PM +0530, Viresh Kumar wrote:
> On 04-03-24, 16:30, Yujie Liu wrote:
> > This fixes the warning for "supply-%d". Seems there are other remaining
> > warnings as shown below. Would you like to take a look as well?
> 
> How about this instead to fix all warnings (drop the earlier change
> please) ?

We see the following errors after applying the new diff:

  CC      drivers/opp/debugfs.o
drivers/opp/debugfs.c: In function 'opp_debug_create_one':
drivers/opp/debugfs.c:92:57: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
   92 |                 snprintf(name, sizeof(name), "rate_hz_%d", i);
      |                                                         ^
In function 'opp_debug_create_clks',
    inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:164:2:
drivers/opp/debugfs.c:92:17: note: 'snprintf' output between 10 and 20 bytes into a destination of size 19
   92 |                 snprintf(name, sizeof(name), "rate_hz_%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/opp/debugfs.c: In function 'opp_debug_create_one':
drivers/opp/debugfs.c:107:56: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=]
  107 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                                                        ^
In function 'opp_debug_create_supplies',
    inlined from 'opp_debug_create_one' at drivers/opp/debugfs.c:165:2:
drivers/opp/debugfs.c:107:17: note: 'snprintf' output between 9 and 19 bytes into a destination of size 18
  107 |                 snprintf(name, sizeof(name), "supply-%d", i);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


An integer has positive and negative limits, and the range is from
-2147483648 to 2147483647 in decimal, so it seems that an integer can
have 11 digits at most.

> 
> diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
> index ec030b19164a..a9ebfdf0b6a1 100644
> --- a/drivers/opp/debugfs.c
> +++ b/drivers/opp/debugfs.c
> @@ -37,10 +37,12 @@ static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
>                             size_t count, loff_t *ppos)
>  {
>         struct icc_path *path = fp->private_data;
> +       const char *name = icc_get_name(path);
>         char buf[64];
> -       int i;
> +       int i = 0;
> 
> -       i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
> +       if (name)
> +               i = scnprintf(buf, sizeof(buf), "%.62s\n", name);
> 
>         return simple_read_from_buffer(userbuf, count, ppos, buf, i);
>  }
> @@ -56,11 +58,11 @@ static void opp_debug_create_bw(struct dev_pm_opp *opp,
>                                 struct dentry *pdentry)
>  {
>         struct dentry *d;
> -       char name[20];
> +       char name[] = "icc-path-XXXXXXXXXX"; /* Integers can take 10 chars max */
>         int i;
> 
>         for (i = 0; i < opp_table->path_count; i++) {
> -               snprintf(name, sizeof(name), "icc-path-%.1d", i);
> +               snprintf(name, sizeof(name), "icc-path-%d", i);
> 
>                 /* Create per-path directory */
>                 d = debugfs_create_dir(name, pdentry);
> @@ -78,7 +80,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp,
>                                   struct opp_table *opp_table,
>                                   struct dentry *pdentry)
>  {
> -       char name[12];
> +       char name[] = "rate_hz_XXXXXXXXXX"; /* Integers can take 10 chars max */
>         int i;
> 
>         if (opp_table->clk_count == 1) {
> @@ -100,7 +102,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
>         int i;
> 
>         for (i = 0; i < opp_table->regulator_count; i++) {
> -               char name[15];
> +               char name[] = "supply-XXXXXXXXXX"; /* Integers can take 10 chars max */
> 
>                 snprintf(name, sizeof(name), "supply-%d", i);
> 
> -- 
> viresh

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

* Re: drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8
  2024-03-05  5:37           ` Yujie Liu
@ 2024-03-05  6:10             ` Viresh Kumar
  0 siblings, 0 replies; 12+ messages in thread
From: Viresh Kumar @ 2024-03-05  6:10 UTC (permalink / raw)
  To: Yujie Liu
  Cc: lkp, linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev

On 05-03-24, 13:37, Yujie Liu wrote:
> An integer has positive and negative limits, and the range is from
> -2147483648 to 2147483647 in decimal, so it seems that an integer can
> have 11 digits at most.

Ah, thanks. Fixed and pushed for linux-next. Diff:

diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c
index ec030b19164a..105de7c3274a 100644
--- a/drivers/opp/debugfs.c
+++ b/drivers/opp/debugfs.c
@@ -37,10 +37,12 @@ static ssize_t bw_name_read(struct file *fp, char __user *userbuf,
                            size_t count, loff_t *ppos)
 {
        struct icc_path *path = fp->private_data;
+       const char *name = icc_get_name(path);
        char buf[64];
-       int i;
+       int i = 0;
 
-       i = scnprintf(buf, sizeof(buf), "%.62s\n", icc_get_name(path));
+       if (name)
+               i = scnprintf(buf, sizeof(buf), "%.62s\n", name);
 
        return simple_read_from_buffer(userbuf, count, ppos, buf, i);
 }
@@ -56,11 +58,11 @@ static void opp_debug_create_bw(struct dev_pm_opp *opp,
                                struct dentry *pdentry)
 {
        struct dentry *d;
-       char name[20];
+       char name[] = "icc-path-XXXXXXXXXXX"; /* Integers can take 11 chars max */
        int i;
 
        for (i = 0; i < opp_table->path_count; i++) {
-               snprintf(name, sizeof(name), "icc-path-%.1d", i);
+               snprintf(name, sizeof(name), "icc-path-%d", i);
 
                /* Create per-path directory */
                d = debugfs_create_dir(name, pdentry);
@@ -78,7 +80,7 @@ static void opp_debug_create_clks(struct dev_pm_opp *opp,
                                  struct opp_table *opp_table,
                                  struct dentry *pdentry)
 {
-       char name[12];
+       char name[] = "rate_hz_XXXXXXXXXXX"; /* Integers can take 11 chars max */
        int i;
 
        if (opp_table->clk_count == 1) {
@@ -100,7 +102,7 @@ static void opp_debug_create_supplies(struct dev_pm_opp *opp,
        int i;
 
        for (i = 0; i < opp_table->regulator_count; i++) {
-               char name[15];
+               char name[] = "supply-XXXXXXXXXXX"; /* Integers can take 11 chars max */
 
                snprintf(name, sizeof(name), "supply-%d", i);


-- 
viresh

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

end of thread, other threads:[~2024-03-05  6:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-06 10:41 drivers/opp/debugfs.c:48:54: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 8 kernel test robot
2023-11-08  6:13 ` Viresh Kumar
  -- strict thread matches above, loose matches on Subject: below --
2023-12-16 22:23 kernel test robot
2023-12-18  6:10 ` Viresh Kumar
2024-02-14  5:43 kernel test robot
2024-02-14  5:58 ` Viresh Kumar
2024-02-21  6:01   ` Liu, Yujie
2024-03-04  6:54     ` Viresh Kumar
2024-03-04  8:30       ` Yujie Liu
2024-03-04 11:21         ` Viresh Kumar
2024-03-05  5:37           ` Yujie Liu
2024-03-05  6:10             ` Viresh Kumar

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