nvme: do not print status message on default#3416
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reduces unsolicited “success”/status output from nvme commands by moving many messages behind a new “verbose-only message” helper, aligning default behavior with Unix composability expectations (clean stdout on success).
Changes:
- Replace a number of unconditional success
printf()/fprintf()calls withnvme_show_verbose_result()/nvme_show_verbose_info(). - Add
nvme_show_verbose_message()to centralize verbose-only messaging in the print layer. - Suppress namespace-management success status output unless
--verboseis set.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| nvme.c | Converts many success/status messages to verbose-only output and adjusts namespace-management status printing. |
| nvme-print.h | Adds convenience macros for verbose-only messaging. |
| nvme-print.c | Implements nvme_show_verbose_message() to gate status output behind verbosity and output format handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
$ ./nvme write /dev/nvme0n1 --start-block=1023 --block-count=0 --data-size=512 --data=nvmetests/TestNVMeCompareCmd/write_file.txt
$ ./nvme write /dev/nvme0n1 --start-block=1023 --block-count=0 --data-size=512 --data=nvmetests/TestNVMeCompareCmd/write_file.txt -v
write: Success
$ ./nvme write /dev/nvme0n1 --start-block=1023 --block-count=0 --data-size=512 --data=nvmetests/TestNVMeCompareCmd/write_file.txt -v -o json
{
"result":"write: Success"
} |
54fc7f8 to
b35f84a
Compare
| if (!err && !nvme_args.verbose && !nvme_is_output_format_normal()) | ||
| return; |
There was a problem hiding this comment.
@copilot: what about this?
if (!err && !nvme_args.verbose && nvme_is_output_format_normal())
return;
| void nvme_show_verbose_message(bool error, const char *msg, ...) | ||
| { | ||
| struct print_ops *ops = nvme_print_ops(NORMAL); | ||
| bool json = nvme_is_output_format_json(); | ||
| va_list ap; | ||
|
|
||
| if (!nvme_args.verbose) | ||
| return; | ||
|
|
||
| va_start(ap, msg); | ||
|
|
||
| if (json) | ||
| ops = nvme_print_ops(JSON); | ||
|
|
||
| if (ops && ops->show_message) | ||
| ops->show_message(json ? error : true, msg, ap); | ||
|
|
||
| va_end(ap); | ||
| } |
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>
b35f84a to
4c5a105
Compare
|
I realize there is a bit more work to do here. Especially if we want to split progress/status infos as unix tool wants to have. Also the whole flag parsing around |
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.
Fixes: #2025
[note: there are plenty more places where nvme-cli still prints directly to stdout. this needs to be updated as well. but given the size of this tasks, let's go incrementatlly]