Skip to content

nvme: standardize nvme_strerror() usage#3093

Merged
igaw merged 4 commits intolinux-nvme:masterfrom
martin-gpy:standardize_nvme_strerror
Feb 18, 2026
Merged

nvme: standardize nvme_strerror() usage#3093
igaw merged 4 commits intolinux-nvme:masterfrom
martin-gpy:standardize_nvme_strerror

Conversation

@martin-gpy
Copy link
Contributor

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with nvme_strerror(...) across CLI, plugins, and libnvme.
  • Update JSON/perror-style helpers to emit nvme_strerror(errno)-based strings.
  • Add missing include in nvme-models.c to access nvme_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.

@martin-gpy martin-gpy force-pushed the standardize_nvme_strerror branch 2 times, most recently from 56b5f7c to 0ba023c Compare February 12, 2026 16:59
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>
@martin-gpy martin-gpy force-pushed the standardize_nvme_strerror branch from 0ba023c to 22a8987 Compare February 12, 2026 17:15
@martin-gpy
Copy link
Contributor Author

@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>
@martin-gpy
Copy link
Contributor Author

@igaw - Are you fine with the responses I posted above? Let me know your thoughts.

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.

@igaw igaw merged commit a781044 into linux-nvme:master Feb 18, 2026
18 of 19 checks passed
@igaw
Copy link
Collaborator

igaw commented Feb 18, 2026

Nice! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants