nvme: standardize nvme_strerror() usage#3093
Conversation
There was a problem hiding this comment.
Pull request overview
Standardizes error string formatting across nvme-cli, plugins, and libnvme by switching from strerror() to nvme_strerror(), enabling consistent messaging for both errno values and libnvme-specific error codes.
Changes:
- Replace
strerror(...)calls withnvme_strerror(...)across CLI, plugins, and libnvme. - Update JSON/perror-style helpers to emit
nvme_strerror(errno)-based strings. - Add missing include in
nvme-models.cto accessnvme_strerror().
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| util/argconfig.c | Switch allocation failure message to nvme_strerror(errno). |
| unit/test-argconfig-parse.c | Switch stderr reopen failure message to nvme_strerror(errno). |
| plugins/wdc/wdc-nvme.c | Replace many strerror(errno) log strings with nvme_strerror(errno). |
| plugins/sandisk/sandisk-utils.c | Replace allocation error strings with nvme_strerror(errno). |
| plugins/sandisk/sandisk-nvme.c | Replace file/alloc/fsync error strings with nvme_strerror(errno). |
| plugins/ocp/ocp-smart-extended-log.c | Replace malloc error string with nvme_strerror(errno). |
| plugins/ocp/ocp-nvme.c | Replace multiple malloc/open/read error strings with nvme_strerror(...). |
| plugins/ocp/ocp-hardware-component-log.c | Replace calloc error string with nvme_strerror(errno). |
| plugins/netapp/netapp-nvme.c | Use nvme_strerror(-err) for negative error codes. |
| plugins/lm/lm-nvme.c | Replace several strerror(errno) uses with nvme_strerror(errno). |
| plugins/huawei/huawei-nvme.c | Replace open error string with nvme_strerror(-ret). |
| plugins/feat/feat-nvme.c | Replace file open/read error strings with nvme_strerror(errno). |
| nvme.c | Replace multiple file I/O/keyring error strings with nvme_strerror(...). |
| nvme-rpmb.c | Replace file open/read error strings with nvme_strerror(errno). |
| nvme-print-json.c | Use nvme_strerror(errno) for JSON “perror” output. |
| nvme-models.c | Add nvme.h include and switch to nvme_strerror(errno) for sysfs/malloc errors. |
| logging.c | Replace debug retry message to use nvme_strerror(errnum). |
| libnvme/src/nvme/tree.c | Replace scan failure strings with nvme_strerror(...). |
| libnvme/src/nvme/nbft.c | Replace fopen/fseek/fread error strings with nvme_strerror(errno). |
| libnvme/src/nvme/json.c | Replace config open error string with nvme_strerror(errno). |
| libnvme/src/nvme/fabrics.c | Replace fabrics device open/read/write error strings with nvme_strerror(errno). |
| fabrics.c | Replace discovery log save/retry error strings with nvme_strerror(...). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
56b5f7c to
0ba023c
Compare
nvme_strerror() is a useful wrapper function for printing proper error messages corresponding to error codes including library specific error codes too. So it would be helpful to standardize the use of the same here across the codebase. Signed-off-by: Martin George <marting@netapp.com>
0ba023c to
22a8987
Compare
|
@igaw - Are you fine with the responses I posted above? Let me know your thoughts. |
Copilot identified an issue with the return handling of nvme_scan_ctrl() which could potentially display a misleading error message by nvme_strerror(). Fix the same. Signed-off-by: Martin George <marting@netapp.com>
Copilot identified an issue with the return handling of get_entity_name() which could potentially display a misleading error message by nvme_strerror(). Fix the same. Signed-off-by: Martin George <marting@netapp.com>
Copilot identified an invalid format specifier in the nvme_show_error() invocation. Fix the same. Signed-off-by: Martin George <marting@netapp.com>
I actually went ahead and added new commits to this same pull request to address the review comments raised by Copilot. So I believe we should be good now. Thanks. |
|
Nice! Thanks a lot! |
nvme_strerror() is a useful wrapper function for printing proper error messages corresponding to error codes including library specific error codes too. So it would be helpful to standardize the use of the same here across the codebase.