diff options
author | Justin Stitt <justinstitt@google.com> | 2024-02-01 19:55:03 +0100 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-02-17 17:16:10 +0100 |
commit | f7b6443f347dd5fdbee15a15f457db83f1426328 (patch) | |
tree | b71372a8a3a03dd4da4f7252e3f06ae6467cddc5 /kernel/capability.c | |
parent | iio: accel: mxc4005: new ACPI ID for the MXC6655 accelerometer (diff) | |
download | linux-f7b6443f347dd5fdbee15a15f457db83f1426328.tar.xz linux-f7b6443f347dd5fdbee15a15f457db83f1426328.zip |
iio: sx9324: avoid copying property strings
We're doing some needless string copies when trying to assign the proper
`prop` string. We can make `prop` a const char* and simply assign to
string literals.
For the case where a format string is used, let's extract the parsing
logic out into sx9324_parse_phase_prop(). We no longer need to create
copies or allocate new memory.
sx9324_parse_phase_prop() will simply return the default def value if it
fails.
This also cleans up some deprecated strncpy() uses [1].
Furthermore, let's clean up this code further by removing some unused
defines:
| #define SX9324_PIN_DEF "semtech,ph0-pin"
| #define SX9324_RESOLUTION_DEF "semtech,ph01-resolution"
| #define SX9324_PROXRAW_DEF "semtech,ph01-proxraw-strength"
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20240201-strncpy-drivers-iio-proximity-sx9324-c-v5-1-78dde23553bc@google.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'kernel/capability.c')
0 files changed, 0 insertions, 0 deletions