i2c: move core from strlcpy to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 11 Aug 2022 12:08:08 +0000 (14:08 +0200)
committerWolfram Sang <wsa@kernel.org>
Thu, 11 Aug 2022 21:02:52 +0000 (23:02 +0200)
Follow the advice of the below link and prefer 'strscpy'. Conversion is
easy because no code used the return value. It has been done with a
simple sed invocation.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-smbus.c

index 10f35f942066aed4745b8593fc2449ee844108b7..91007558bcb26012716bc0bbe95f57097cb4fc5d 100644 (file)
@@ -933,7 +933,7 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf
                client->init_irq = i2c_dev_irq_from_resources(info->resources,
                                                         info->num_resources);
 
-       strlcpy(client->name, info->type, sizeof(client->name));
+       strscpy(client->name, info->type, sizeof(client->name));
 
        status = i2c_check_addr_validity(client->addr, client->flags);
        if (status) {
index 775332945ad04522ddd482e3b032641e10eaffbe..8ba9b59a3c40fde52bd0b59564185c5eaeecdac9 100644 (file)
@@ -391,7 +391,7 @@ void i2c_register_spd(struct i2c_adapter *adap)
                unsigned short addr_list[2];
 
                memset(&info, 0, sizeof(struct i2c_board_info));
-               strlcpy(info.type, name, I2C_NAME_SIZE);
+               strscpy(info.type, name, I2C_NAME_SIZE);
                addr_list[0] = 0x50 + n;
                addr_list[1] = I2C_CLIENT_END;