btrfs: Replace deprecated strncpy() with strscpy()
PATCH v2 1/1 btrfs: Replace deprecated strncpy() with strscpy()
strncpy() is deprecated for NUL-terminated destination buffers. Use strscpy() instead and don't zero-initialize the param array.
Compile-tested only.
Signed-off-by Thorsten Blum <[email protected]>
---
Changes in v2:
- Use strscpy() instead of strscpy_pad() as suggested by David Sterba
- Link to v1: https://lore.kernel.org/r/[email protected]/
--- fs/btrfs/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/sysfs.c +2 -2
@@ -1330,13 +1330,13 @@ MODULE_PARM_DESC(read_policy,int btrfs_read_policy_to_enum (const char *str,s64 *value_ret) { -char param[32 ] = {0 }; +char param[32 ];char __maybe_unused *value_str;if (!str ||strlen (str) ==0 )return 0 ; -strncpy (param, str,sizeof (param) -1 ); +strscpy (param, str);#ifdef CONFIG_BTRFS_EXPERIMENTAL /* Separate value from input in policy:value format. */
Signature · 1 line
2.48.1
Quoted 8 lines · Thorsten Blum
strncpy()is deprecated for NUL-terminated destination buffers. Usestrscpy()instead and don't zero-initialize the param array.Compile-tested only.
Added to for-next, thanks.