docs: stop suggesting strlcpy
Since strlcpy is deprecated, the documentation shouldn't suggest using it. This patch fixes the examples to use strscpy instead. It also uses sizeof instead of underlying constants as far as possible, to simplify future changes to the corresponding data structures. Signed-off-by: Stephen Kitt <steve@sk2.org> Acked-by: Kees Cook <keescook@chromium.org> Acked-by: Federico Vaga <federico.vaga@vaga.pv.it> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:

committed by
Jonathan Corbet

parent
4ae5b8f214
commit
220ee02a0b
@@ -43,7 +43,7 @@ static int example_attach(struct i2c_adapter *adap, int addr, int kind)
|
||||
example->client.adapter = adap;
|
||||
|
||||
i2c_set_clientdata(&state->i2c_client, state);
|
||||
strlcpy(client->i2c_client.name, "example", I2C_NAME_SIZE);
|
||||
strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name));
|
||||
|
||||
ret = i2c_attach_client(&state->i2c_client);
|
||||
if (ret < 0) {
|
||||
@@ -138,7 +138,7 @@ can be removed:
|
||||
- example->client.flags = 0;
|
||||
- example->client.adapter = adap;
|
||||
-
|
||||
- strlcpy(client->i2c_client.name, "example", I2C_NAME_SIZE);
|
||||
- strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name));
|
||||
|
||||
The i2c_set_clientdata is now:
|
||||
|
||||
|
Reference in New Issue
Block a user