History

iio: change strncpy+truncation to strlcpy

Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Dominique Martinet committed 8 years ago

Commit cd570e61 parent ef89f4b2 files · +2 −4Browse files

Unified · Split

2 files
  1. drivers/iio/common/st_sensors/st_sensors_core.c +1 −2
  2. drivers/iio/pressure/st_pressure_i2c.c +1 −2
drivers/iio/common/st_sensors/st_sensors_core.c+1−2
@@ -380,8 +380,7 @@ void st_sensors_of_name_probe(struct device *dev, · 379 unmodified lines
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+1−2
@@ -94,9 +94,8 @@ static int st_press_i2c_probe(struct i2c_client *client, · 93 unmodified lines
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