Skip to content

Commit cd570e6

Browse files
martinetdjic23
authored andcommitted
iio: change strncpy+truncation to strlcpy
Generated by scripts/coccinelle/misc/strncpy_truncation.cocci Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent ef89f4b commit cd570e6

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

drivers/iio/common/st_sensors/st_sensors_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,7 @@ void st_sensors_of_name_probe(struct device *dev,
380380
return;
381381

382382
/* The name from the OF match takes precedence if present */
383-
strncpy(name, of_id->data, len);
384-
name[len - 1] = '\0';
383+
strlcpy(name, of_id->data, len);
385384
}
386385
EXPORT_SYMBOL(st_sensors_of_name_probe);
387386
#else

drivers/iio/pressure/st_pressure_i2c.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ static int st_press_i2c_probe(struct i2c_client *client,
9494
if ((ret < 0) || (ret >= ST_PRESS_MAX))
9595
return -ENODEV;
9696

97-
strncpy(client->name, st_press_id_table[ret].name,
97+
strlcpy(client->name, st_press_id_table[ret].name,
9898
sizeof(client->name));
99-
client->name[sizeof(client->name) - 1] = '\0';
10099
} else if (!id)
101100
return -ENODEV;
102101

0 commit comments

Comments
 (0)