Generated by scripts/coccinelle/misc/strncpy_truncation.cocci
Unified · Split
| @@ -380,8 +380,7 @@ void st_sensors_of_name_probe(struct device *dev, · 379 unmodified lines | ||
| 380 | 380 | return; |
| 381 | 381 | |
| 382 | 382 | /* 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); | |
| 385 | 384 | } |
| 386 | 385 | EXPORT_SYMBOL(st_sensors_of_name_probe); |
| 387 | 386 | #else |
| @@ -94,9 +94,8 @@ static int st_press_i2c_probe(struct i2c_client *client, · 93 unmodified lines | ||
| 94 | 94 | if ((ret < 0) || (ret >= ST_PRESS_MAX)) |
| 95 | 95 | return -ENODEV; |
| 96 | 96 | |
| 97 | − strncpy(client->name, st_press_id_table[ret].name, | |
| 97 | + strlcpy(client->name, st_press_id_table[ret].name, | |
| 98 | 98 | sizeof(client->name)); |
| 99 | − client->name[sizeof(client->name) - 1] = '\0'; | |
| 100 | 99 | } else if (!id) |
| 101 | 100 | return -ENODEV; |
| 102 | 101 | |