[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <202501291646.VtwF98qd-lkp@intel.com>
Date: Wed, 29 Jan 2025 16:08:34 +0800
From: kernel test robot <lkp@...el.com>
To: Maximilian Luz <luzmaximilian@...il.com>
Cc: llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev,
linux-kernel@...r.kernel.org, Hans de Goede <hdegoede@...hat.com>,
Andy Shevchenko <andy.shevchenko@...il.com>
Subject: drivers/platform/surface/surface3_power.c:243:2: warning: 'snprintf'
will always be truncated; specified size is 10, but format string expands to
at least 12
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 05dbaf8dd8bf537d4b4eb3115ab42a5fb40ff1f5
commit: 85f7582cd484dbf491b6d9bb2af6ef1467a024d2 platform/surface: Move Surface 3 Power OpRegion driver to platform/surface
date: 4 years, 3 months ago
config: x86_64-randconfig-071-20241231 (https://download.01.org/0day-ci/archive/20250129/202501291646.VtwF98qd-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250129/202501291646.VtwF98qd-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501291646.VtwF98qd-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/platform/surface/surface3_power.c:243:2: warning: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 12 [-Wformat-truncation-non-kprintf]
243 | snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%6pE", buf + 7, buf);
| ^
1 warning generated.
vim +/snprintf +243 drivers/platform/surface/surface3_power.c
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 207
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 208 static int mshw0011_bix(struct mshw0011_data *cdata, struct bix *bix)
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 209 {
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 210 struct i2c_client *client = cdata->bat0;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 211 char buf[SURFACE_3_STRLEN];
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 212 int ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 213
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 214 *bix = default_bix;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 215
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 216 /* get design capacity */
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 217 ret = i2c_smbus_read_word_data(client,
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 218 MSHW0011_BAT0_REG_DESIGN_CAPACITY);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 219 if (ret < 0) {
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 220 dev_err(&client->dev, "Error reading design capacity: %d\n",
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 221 ret);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 222 return ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 223 }
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 224 bix->design_capacity = ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 225
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 226 /* get last full charge capacity */
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 227 ret = i2c_smbus_read_word_data(client,
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 228 MSHW0011_BAT0_REG_FULL_CHG_CAPACITY);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 229 if (ret < 0) {
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 230 dev_err(&client->dev,
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 231 "Error reading last full charge capacity: %d\n", ret);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 232 return ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 233 }
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 234 bix->last_full_charg_capacity = ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 235
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 236 /* get serial number */
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 237 ret = i2c_smbus_read_i2c_block_data(client, MSHW0011_BAT0_REG_SERIAL_NO,
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 238 sizeof(buf), buf);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 239 if (ret != sizeof(buf)) {
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 240 dev_err(&client->dev, "Error reading serial no: %d\n", ret);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 241 return ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 242 }
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 @243 snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%6pE", buf + 7, buf);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 244
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 245 /* get cycle count */
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 246 ret = i2c_smbus_read_word_data(client, MSHW0011_BAT0_REG_CYCLE_CNT);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 247 if (ret < 0) {
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 248 dev_err(&client->dev, "Error reading cycle count: %d\n", ret);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 249 return ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 250 }
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 251 bix->cycle_count = ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 252
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 253 /* get OEM name */
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 254 ret = i2c_smbus_read_i2c_block_data(client, MSHW0011_BAT0_REG_OEM,
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 255 4, buf);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 256 if (ret != 4) {
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 257 dev_err(&client->dev, "Error reading cycle count: %d\n", ret);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 258 return ret;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 259 }
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 260 snprintf(bix->OEM, ARRAY_SIZE(bix->OEM), "%3pE", buf);
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 261
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 262 return 0;
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 263 }
b1f81b496b0d14 drivers/platform/x86/surface3_power.c Blaž Hrastnik 2020-03-21 264
:::::: The code at line 243 was first introduced by commit
:::::: b1f81b496b0d14382a9cf160cc4dbdefb233f936 platform/x86: surface3_power: MSHW0011 rev-eng implementation
:::::: TO: Blaž Hrastnik <blaz@...n.io>
:::::: CC: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists