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:
Stephen Kitt
2019-06-13 18:25:48 +02:00
committed by Jonathan Corbet
parent 4ae5b8f214
commit 220ee02a0b
5 changed files with 12 additions and 12 deletions

View File

@@ -451,7 +451,7 @@ to protect the cache and all the objects within it. Here's the code::
if ((obj = kmalloc(sizeof(*obj), GFP_KERNEL)) == NULL)
return -ENOMEM;
strlcpy(obj->name, name, sizeof(obj->name));
strscpy(obj->name, name, sizeof(obj->name));
obj->id = id;
obj->popularity = 0;
@@ -660,7 +660,7 @@ Here is the code::
}
@@ -63,6 +94,7 @@
strlcpy(obj->name, name, sizeof(obj->name));
strscpy(obj->name, name, sizeof(obj->name));
obj->id = id;
obj->popularity = 0;
+ obj->refcnt = 1; /* The cache holds a reference */
@@ -774,7 +774,7 @@ the lock is no longer used to protect the reference count itself.
}
@@ -94,7 +76,7 @@
strlcpy(obj->name, name, sizeof(obj->name));
strscpy(obj->name, name, sizeof(obj->name));
obj->id = id;
obj->popularity = 0;
- obj->refcnt = 1; /* The cache holds a reference */