nvme: do not print status message on default#3553
Merged
Merged
Conversation
After the final json_print_object add a newline so that the output doesn't interfere with the shell command line print afterwards. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Add variants of nvme_show_verbose_* which will only print when verbose mode is enabled. Signed-off-by: Daniel Wagner <wagi@kernel.org>
Don't print empty json output. Signed-off-by: Daniel Wagner <wagi@kernel.org>
There can only be one JSON root object, thus create it at after parsing the options and print it when existing the program. With this in place, it's possible remove embedded creation of json_r object. It will always exist when those code paths are hit. Signed-off-by: Daniel Wagner <dwagner@suse.com>
igaw
force-pushed
the
do-not-print-status-messages
branch
from
July 7, 2026 07:28
a09d12e to
4dea663
Compare
There was a problem hiding this comment.
Pull request overview
This PR aligns nvme-cli and its plugins with the Unix convention of being silent on success and keeping stdout clean for machine-consumable output, by moving many status/diagnostic messages behind verbose helpers and/or to stderr.
Changes:
- Replaces many direct
printf/fprintf(stderr, ...)/perrorsites withnvme_show_*helpers for consistent routing/formatting. - Introduces verbose-only printing helpers (
nvme_show_verbose_message,nvme_show_verbose_result/info,nvme_show_verbose_key_value) and updates multiple plugins to use them. - Adds explicit trailing newlines after some JSON prints to ensure valid line-oriented JSON output.
Reviewed changes
Copilot reviewed 55 out of 56 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/zns/zns.c | Moves ZNS plugin success/status/error messaging to nvme_show_* helpers and verbose-only output. |
| plugins/wdc/wdc-utils.c | Converts error printing to nvme_show_error. |
| plugins/virtium/virtium-nvme.c | Adds nvme-print.h and switches multiple user messages to nvme_show_error / verbose helpers. |
| plugins/transcend/transcend-nvme.c | Adds nvme-print.h and switches “Device not found” output to nvme_show_error. |
| plugins/toshiba/toshiba-nvme.c | Converts stderr diagnostics to nvme_show_error. |
| plugins/solidigm/solidigm-workload-tracker.c | Minor message formatting change via nvme_show_error. |
| plugins/solidigm/solidigm-temp-stats.c | Switches a stderr error to nvme_show_error. |
| plugins/solidigm/solidigm-telemetry.c | Reworks argument-validation errors to nvme_show_error / nvme_show_err. |
| plugins/solidigm/solidigm-smart.c | Converts invalid-format error output to nvme_show_error. |
| plugins/solidigm/solidigm-log-page-dir.c | Tweaks invalid-format message formatting via nvme_show_error. |
| plugins/solidigm/solidigm-latency-tracking.c | Routes errors to nvme_show_error / nvme_show_err and success to verbose helpers. |
| plugins/solidigm/solidigm-internal-logs.c | Switches perror/printf success messages to nvme_show_perror and verbose helpers. |
| plugins/solidigm/solidigm-garbage-collection.c | Converts invalid-format message to nvme_show_error. |
| plugins/shannon/shannon-nvme.c | Converts stderr/perror/status handling to nvme_show_error / nvme_show_err. |
| plugins/sed/sedopal_cmd.c | Adds nvme-print.h and converts many stderr messages to nvme_show_error. |
| plugins/sed/sed.c | Converts stderr messages to nvme_show_error. |
| plugins/seagate/seagate-nvme.c | Adds explicit \n after JSON output and converts several messages to nvme_show_error / nvme_show_err. |
| plugins/scaleflux/sfx-nvme.c | Converts several messages to nvme_show_error / nvme_show_err and gates success output behind verbose helpers. |
| plugins/sandisk/sandisk-utils.c | Converts stderr error messages to nvme_show_error. |
| plugins/sandisk/sandisk-nvme.c | Converts many stderr messages to nvme_show_error / nvme_show_err and adjusts telemetry/resize messaging. |
| plugins/registry/registry-nvme.c | Adds nvme-print.h and converts user prompts/errors to nvme_show_error. |
| plugins/ocp/ocp-telemetry-decode.c | Converts messages to nvme_show_error and removes some embedded newlines. |
| plugins/ocp/ocp-smart-extended-log.c | Converts stderr messages to nvme_show_error and adjusts GUID mismatch messaging. |
| plugins/ocp/ocp-print.c | Routes “unhandled output format” to nvme_show_error. |
| plugins/ocp/ocp-hardware-component-log.c | Converts info-level stderr printing macro to nvme_show_error. |
| plugins/ocp/ocp-fw-activation-history.c | Converts stderr messages to nvme_show_error. |
| plugins/ocp/ocp-clear-features.c | Gates “Success” behind verbose helper and routes failures to nvme_show_error. |
| plugins/netapp/netapp-nvme.c | Adds nvme-print.h and converts many stderr diagnostics to nvme_show_error. |
| plugins/micron/micron-utils-win.c | Adds nvme-print.h and routes platform-not-supported messages to nvme_show_error. |
| plugins/micron/micron-utils-linux.c | Adds nvme-print.h and converts perror/printf to nvme_show_perror / nvme_show_error / verbose helpers. |
| plugins/memblaze/memblaze-nvme.c | Converts success/failure messaging to nvme_show_error / nvme_show_err / verbose helpers. |
| plugins/lm/lm-print.c | Adds nvme-print.h and routes “unhandled output format” to nvme_show_error. |
| plugins/lm/lm-print-stdout.c | Adds nvme-print.h and routes warnings to nvme_show_error. |
| plugins/lm/lm-print-json.c | Adds nvme-print.h and routes warnings to nvme_show_error. |
| plugins/lm/lm-nvme.c | Gates several “Successful” messages behind verbose helpers. |
| plugins/intel/intel-nvme.c | Adds \n after JSON output and routes various messages through nvme_show_error / nvme_show_perror / verbose helpers. |
| plugins/innogrit/innogrit-nvme.c | Converts some printf error markers to nvme_show_error. |
| plugins/ibm/ibm-nvme.c | Converts error messages to nvme_show_error / nvme_show_perror. |
| plugins/huawei/huawei-nvme.c | Adds nvme-print.h and routes allocation/open failures to nvme_show_error. |
| plugins/feat/feat-nvme.c | Removes nvme_show_init/finish wrappers around some outputs. |
| plugins/fdp/fdp.c | Converts stderr/perror/success prints to nvme_show_error / nvme_show_err / verbose helpers. |
| plugins/exclusion/exclusion-nvme.c | Adds nvme-print.h and converts many stderr messages to nvme_show_error. |
| plugins/amzn/amzn-nvme.c | Converts stderr messages to nvme_show_error. |
| plugin.c | Routes invalid sub-command errors to stderr (instead of stdout). |
| nvme-rpmb.c | Converts many stderr prints to nvme_show_error / nvme_show_perror and uses nvme_show_result for data output. |
| nvme-print.h | Adds verbose result/info macros and new verbose helper declarations. |
| nvme-print.c | Refactors message/key-value helpers and introduces verbose variants. |
| nvme-print-stdout.c | Fixes negative-status strerror usage. |
| nvme-models.c | Adds nvme-print.h and routes several errors through nvme_show_error. |
| logging.c | Replaces some stdout debug prints with structured key/value helpers. |
| fabrics.c | Routes many messages through nvme_show_error / verbose helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
113
to
120
| if (err < 0) | ||
| nvme_show_error("ERROR: nvme_lm_cdq() failed: %s", libnvme_strerror(errno)); | ||
| else if (err) | ||
| nvme_show_status(err); | ||
| else | ||
| printf("Create CDQ Successful: CDQID=0x%04x\n", | ||
| nvme_show_verbose_result("Create CDQ Successful: CDQID=0x%04x", | ||
| NVME_GET((__u32)cmd.result, LM_CREATE_CDQ_CDQID)); | ||
|
|
igaw
force-pushed
the
do-not-print-status-messages
branch
from
July 7, 2026 07:55
4dea663 to
9c93b8f
Compare
Unix tools should remain silent on success and produce output only when it is part of their functional result. Emitting status messages by default violates the long-established convention that stdout is reserved for machine-consumable data, while diagnostics and optional progress reporting belong on stderr or behind an explicit verbose flag. A core strength of Unix tooling is composability: commands are routinely used in pipelines, shell scripts, automation frameworks, and other programs. Unsolicited status output contaminates stdout, forcing consumers to implement fragile filtering logic and making the tool harder to integrate reliably. The absence of default status messages is therefore not merely a stylistic preference but an interoperability requirement. This follows the traditional Unix principle that "no news is good news": successful execution is indicated by the exit status, not by human-readable confirmation text. Users who need operational visibility can opt into it through verbose or progress-reporting options, while automation and existing workflows continue to receive clean, deterministic output. Signed-off-by: Daniel Wagner <wagi@kernel.org>
The error code is stored in status not errno. Signed-off-by: Daniel Wagner <wagi@kernel.org>
igaw
force-pushed
the
do-not-print-status-messages
branch
from
July 7, 2026 08:00
9c93b8f to
5b9e34a
Compare
Collaborator
|
While this not addressing all the issues the code base has, it is going into the right direction. There are more cleanups needed. Let's get this in and fixup the rest piece by piece. There is no point trying to fix everything in one go. |
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #2025
Replaces: #3416