Thread (6 messages) 6 messages, 3 authors, 2022-01-17

Re: [PATCH V2 1/1] nvme: Add verbose error logging

From: Keith Busch <kbusch@kernel.org>
Date: 2021-12-27 16:07:51

On Thu, Dec 23, 2021 at 01:57:26PM -0800, Alan Adamson wrote:
+
+static const char * const nvme_errors[] = {
+	"Success",
+	"Invalid Command Opcode",
+	"Invalid Field in Command",
+	"Command ID Conflict",
+	"Data Transfer Error",
+	"Commands Aborted due to Power Loss Notification",
+	"Internal Error",
+	"Command Abort Requested",
+	"Command Aborted due to SQ Deletion",
+	"Command Aborted due to Failed Fused Command",
+	"Command Aborted due to Missing Fused Command",
+	"Invalid Namespace or Format",
+	"Command Sequence Error",
+	"Invalid SGL Segment Descriptor",
+	"Invalid Number of SGL Descriptors",
+	"Data SGL Length Invalid",
+	"Metadata SGL Length Invalid",
+	"SGL Descriptor Type Invalid",
+	"Invalid Use of Controller Memory Buffer",
+	"PRP Offset Invalid",
+	"Atomic Write Unit Exceeded",
+	"Operation Denied",
+	"SGL Offset Invalid",
+	"Reserved",
+	"Host Identifier Inconsistent Format",
+	"Keep Alive Timeout Expired",
+	"Keep Alive Timeout Invalid",
+	"Command Aborted due to Preempt and Abort",
+	"Sanitize Failed",
+	"Sanitize In Progress",
+	"SGL Data Block Granularity Invalid",
+	"Command Not Supported for Queue in CMB",
+	"Namespace is Write Protected",
+	"Command Interrupted",
+	"Transient Transport Error",
+	NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
Tracking these NULL's is going to be problematic and error prone.

I recommend indexing the strings as you define them. For example:

static const char * const nvme_errors[] = {
	[NVME_SC_SUCCESS] = "Success",
	[NVME_SC_INVALID_OPCODE] = "Invalid Command Opcode",

etc...

Then you don't need to bother tracking the undefined indexes or making
sure everything is in order.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help