Skip to contentSkip to conversation

libcxl: Remove extraneous NULL checks when validating cmd status

PATCH In review [email protected] 2 participants 2 messages Mar 3, 2022 libnvdimm: non-volatile memory device

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 libcxl: Remove extraneous NULL checks when validating cmd status

From: Alison Schofield <[email protected]>

When a cxl_cmd_new_*() function is executed the returned command pointer is always checked for NULL. Remove extraneous NULL checks later in the command validation path.

Coverity pointed these out as 'check_after_deref' issues.

---
 cxl/lib/libcxl.c | 4 ----
 1 file changed, 4 deletions(-)
cxl/lib/libcxl.c +0 -4
index daa2bbc5a299..f111d8681669 100644
@@ -2283,8 +2283,6 @@ cmd_to_identify(struct cxl_cmd *cmd)
 	if (cxl_cmd_validate_status(cmd, CXL_MEM_COMMAND_ID_IDENTIFY))
 		return NULL;
 
-	if (!cmd)
-		return NULL;
 	return cmd->output_payload;
 }
 
@@ -2429,8 +2427,6 @@ cmd_to_get_partition(struct cxl_cmd *cmd)
 	if (cxl_cmd_validate_status(cmd, CXL_MEM_COMMAND_ID_GET_PARTITION_INFO))
 		return NULL;
 
-	if (!cmd)
-		return NULL;
 	return cmd->output_payload;
 }
 

base-commit: 3b5fb8b6428dfaab39bab58d67412427f514c1f4

Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Thu, Mar 3, 2022 at 3:13 PM <[email protected]> wrote:

From: Alison Schofield <[email protected]>

When a cxl_cmd_new_*() function is executed the returned command pointer is always checked for NULL. Remove extraneous NULL checks later in the command validation path.

Coverity pointed these out as 'check_after_deref' issues.

LGTM: