Skip to content

nvme: fix the JSON document count and label the remaining error messages - #4231

Merged
igaw merged 2 commits into
linux-nvme:masterfrom
dwsuse:cli-output-fixes
Oct 21, 2026
Merged

igaw merged 2 commits into
linux-nvme:masterfrom
dwsuse:cli-output-fixes

Conversation

@dwsuse

@dwsuse dwsuse commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Two fixes, split out of the decoder sandbox work (#4183):

nvme-print-json: don't finish a document which was not started

nvme_main() finishes the output even if no command started a document, e.g. after a usage error. json_show_finish() then counts json_init below zero, and the next document is never printed. This hits the fuzz tests, which run nvme_main() over and over.

nvme: start the remaining error messages with a label

Since 32f59da the errors of a command start with its name. A few messages still print their own ERROR: prefix:

$ nvme id crrl
ERROR: Invalid sub-command 'crrl' for plugin id
$ nvme id ctrl /dev/nvme0
id ctrl: /dev/nvme0: Permission denied

argconfig_error() labels a message the way the usage errors are labelled: with the command name, or before a command runs with the program name. The plugin dispatch and the privilege separation use it now (id: invalid sub-command 'crrl'). The two checks of the deprecated tls-key command become usage errors, and a negative status no longer prints id ctrl: Error: ....

The e2e tests detect a missing sub-command by its error message, also on older nvme-cli versions; they now match it case-insensitively.

Tested: full test suite, both commits built on their own, checkpatch with the CI filter.

nvme_main() finishes the output even if no command started a document,
e.g. after a usage error. json_show_finish() then counts json_init below
zero, and the next document is not printed. This hits the fuzz tests,
which run nvme_main() over and over. Ignore a finish without a start.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
The errors of a command start with its name since commit 32f59da
("nvme: start the error messages with the name of the command"), the
usage errors before a command runs with the program name. Some messages
still start with "ERROR:" instead, e.g.

  $ nvme id crrl
  ERROR: Invalid sub-command 'crrl' for plugin id
  $ nvme id ctrl /dev/nvme0
  id ctrl: /dev/nvme0: Permission denied

Add argconfig_error(), which labels a message as the usage errors do,
and use it for the errors of the plugin dispatch and of the privilege
separation, which run before or around a command:

  id: invalid sub-command 'crrl'

The two checks of the deprecated tls-key command are usage errors and
now print its usage as well. A negative status no longer adds "Error:"
after the label.

The e2e tests detect a missing sub-command by its error message, also
of older nvme-cli versions. Match it case-insensitively.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
@igaw
igaw merged commit a1af392 into linux-nvme:master Oct 21, 2026
34 checks passed
@dwsuse
dwsuse deleted the cli-output-fixes branch October 23, 2026 10:23
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.

2 participants