diff options
| author | Justin Stitt <[email protected]> | 2023-09-27 05:10:54 +0000 |
|---|---|---|
| committer | Lee Jones <[email protected]> | 2023-11-01 10:02:14 +0000 |
| commit | 6bce629689f094bb7729ac77567a76763912b392 (patch) | |
| tree | 162de532f6bcd0cfcf37e2eae82e192e247d4502 /scripts/stackusage | |
| parent | 61fdd1f1d2c183ec256527d16d75e75c3582af82 (diff) | |
mfd: db8500-prcmu: Replace deprecated strncpy with strscpy
`strncpy` is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.
We expect project_name to be NUL-terminated based on its use with
pr_info:
| pr_info("PRCMU firmware: %s(%d), version %d.%d.%d\n",
| fw_info.version.project_name,
| fw_info.version.project,
| fw_info.version.api_version,
| fw_info.version.func_version,
| fw_info.version.errata);
Moreover, NUL-padding does not seem to be needed.
Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.
Let's also change `PRCMU_FW_PROJECT_NAME_LEN` to just
sizeof(fw_info.version.project_name) as this is more idiomatic strscpy
usage.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: [email protected]
Signed-off-by: Justin Stitt <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Link: https://lore.kernel.org/r/20230927-strncpy-drivers-mfd-db8500-prcmu-c-v1-1-db9693f92a68@google.com
Signed-off-by: Lee Jones <[email protected]>
Diffstat (limited to 'scripts/stackusage')
0 files changed, 0 insertions, 0 deletions