Commit 301cfbc1 authored by Minghao Chi's avatar Minghao Chi Committed by Sebastian Reichel

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: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarMinghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 3639dbd7
...@@ -384,7 +384,7 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl) ...@@ -384,7 +384,7 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl)
} }
if (!info->ManufacturerName[0]) if (!info->ManufacturerName[0])
strncpy(info->ManufacturerName, DEF_MFG_NAME, strscpy(info->ManufacturerName, DEF_MFG_NAME,
2 * MAX1721X_REG_MFG_NUMB); 2 * MAX1721X_REG_MFG_NUMB);
if (get_string(info, MAX1721X_REG_DEV_STR, if (get_string(info, MAX1721X_REG_DEV_STR,
...@@ -403,15 +403,15 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl) ...@@ -403,15 +403,15 @@ static int devm_w1_max1721x_add_device(struct w1_slave *sl)
switch (dev_name & MAX172XX_DEV_MASK) { switch (dev_name & MAX172XX_DEV_MASK) {
case MAX172X1_DEV: case MAX172X1_DEV:
strncpy(info->DeviceName, DEF_DEV_NAME_MAX17211, strscpy(info->DeviceName, DEF_DEV_NAME_MAX17211,
2 * MAX1721X_REG_DEV_NUMB); 2 * MAX1721X_REG_DEV_NUMB);
break; break;
case MAX172X5_DEV: case MAX172X5_DEV:
strncpy(info->DeviceName, DEF_DEV_NAME_MAX17215, strscpy(info->DeviceName, DEF_DEV_NAME_MAX17215,
2 * MAX1721X_REG_DEV_NUMB); 2 * MAX1721X_REG_DEV_NUMB);
break; break;
default: default:
strncpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN, strscpy(info->DeviceName, DEF_DEV_NAME_UNKNOWN,
2 * MAX1721X_REG_DEV_NUMB); 2 * MAX1721X_REG_DEV_NUMB);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment