Skip to content

Commit 301cfbc

Browse files
Minghao Chisre
authored andcommitted
power: supply: max1721x: Use strscpy() is more robust and safer
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Reported-by: Zeal Robot <[email protected]> Signed-off-by: Minghao Chi <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 3639dbd commit 301cfbc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/power/supply/max1721x_battery.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl)
384384
}
385385

386386
if (!info->ManufacturerName[0])
387-
strncpy(info->ManufacturerName, DEF_MFG_NAME,
387+
strscpy(info->ManufacturerName, DEF_MFG_NAME,
388388
2 * MAX1721X_REG_MFG_NUMB);
389389

390390
if (get_string(info, MAX1721X_REG_DEV_STR,
@@ -403,15 +403,15 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl)
403403

404404
switch (dev_name & MAX172XX_DEV_MASK) {
405405
case MAX172X1_DEV:
406-
strncpy(info->DeviceName, DEF_DEV_NAME_MAX17211,
406+
strscpy(info->DeviceName, DEF_DEV_NAME_MAX17211,
407407
2 * MAX1721X_REG_DEV_NUMB);
408408
break;
409409
case MAX172X5_DEV:
410-
strncpy(info->DeviceName, DEF_DEV_NAME_MAX17215,
410+
strscpy(info->DeviceName, DEF_DEV_NAME_MAX17215,
411411
2 * MAX1721X_REG_DEV_NUMB);
412412
break;
413413
default:
414-
strncpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN,
414+
strscpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN,
415415
2 * MAX1721X_REG_DEV_NUMB);
416416
}
417417
}

0 commit comments

Comments
 (0)