diff options
author | Marcelo Moreira <marcelomoreira1905@gmail.com> | 2025-04-03 20:23:56 -0300 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2025-05-20 05:34:25 +0200 |
commit | 5df496e9ef12e85dcc21488069bbf1b0285aca00 (patch) | |
tree | 5a1267acc33bca07063c7128361498e8d37d5125 /tools/perf/scripts/python/exported-sql-viewer.py | |
parent | 674f872b7cefab4564ec8b34c799a4a653e34513 (diff) |
nvmet: replace strncpy with strscpy
The strncpy() function is deprecated for NUL-terminated strings as
explained in the "strncpy() on NUL-terminated strings" section of
Documentation/process/deprecated.rst.
The key issues are:
- strncpy() fails to guarantee NULL-termination when source > destination
- it unnecessarily zero-pads short strings, causing performance overhead
strscpy() is the proper replacement because:
- it guarantees NULL-termination
- it avoids redundant zero-padding
- it aligns with current kernel string-copying best practice
memcpy() was rejected because:
- NQN buffers (subsysnqn/hostnqn) are treated as NULL-terminated strings:
- strcmp() usage in nvmet_host_allowed() (discovery.c)
- strscpy() to copy subsysnqn in nvmet_execute_disc_identify()
seq_buf wasn't used because:
- this is a simple fixed-size buffer copy
- there is no need for progressive string construction features
Signed-off-by: Marcelo Moreira <marcelomoreira1905@gmail.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'tools/perf/scripts/python/exported-sql-viewer.py')
0 files changed, 0 insertions, 0 deletions