ndctl/cxl: Remove unnecessary null check
PATCH 1/1 ndctl/cxl: Remove unnecessary null check
cmd->query_cmd can never be null in cxl_cmd_alloc_send(). The only call chain is:
cxl_cmd_do_query(cmd);
cxl_cmd_validate(cmd, cmd_id);
cxl_cmd_alloc_send(cmd, cmd_id);And cxl_cmd_do_query() ensures it is non-null. In addition the local variable query is already dereferenced by the time it is checked for null.
Remove the unneeded null check.
---
Minor fix I found while working on the kernel side query command.
--- cxl/lib/libcxl.c | 3 --- 1 file changed, 3 deletions(-)
cxl/lib/libcxl.c +0 -3
@@ -3091,9 +3091,6 @@ static int cxl_cmd_alloc_send(struct cxl_cmd *cmd, u32 cmd_id)struct cxl_command_info *cinfo = &query->commands[cmd->query_idx];size_t size; -if (!query) -return -EINVAL ; - size =sizeof (struct cxl_send_command ); cmd->send_cmd =calloc (1 , size);if (!cmd->send_cmd)
---
base-commit: b73e4e0390aae822bc91b8bf72430e6f0e84d668
change-id: 20230201-update_query-ad2845ba197a
Best regards,
Signature · 1 line
Ira Weiny <[email protected]>
Quoted 7 lines · Ira Weiny
cmd->query_cmdcan never be null incxl_cmd_alloc_send(). The only call chain is:cxl_cmd_do_query(cmd); cxl_cmd_validate(cmd, cmd_id); cxl_cmd_alloc_send(cmd, cmd_id);
Quoted 6 lines
And
cxl_cmd_do_query()ensures it is non-null. In addition the local variable query is already dereferenced by the time it is checked for null.Remove the unneeded null check.
Signed-off-by Ira Weiny <[email protected]>
Quoted 26 lines
---
Minor fix I found while working on the kernel side query command.--- cxl/lib/libcxl.c | 3 --- 1 file changed, 3 deletions(-)cxl/lib/libcxl.c +0
-4@@ -3091,9 +3091,6 @@ static int cxl_cmd_alloc_send(struct cxl_cmd *cmd, u32 cmd_id)struct cxl_command_info *cinfo = &query->commands[cmd->query_idx];size_t size; -if (!query) -return -EINVAL ; - size =sizeof (struct cxl_send_command ); cmd->send_cmd =calloc (1 , size);if (!cmd->send_cmd) ---base-commit:
b73e4e0390aae822bc91b8bf72430e6f0e84d668
change-id: 20230201-update_query-ad2845ba197aBest regards,
Quoted 10 lines · Ira Weiny
cmd->query_cmdcan never be null in cxl_cmd_alloc_send(). The only call chain is:
cxl_cmd_do_query(cmd);
cxl_cmd_validate(cmd, cmd_id);
cxl_cmd_alloc_send(cmd, cmd_id);And
cxl_cmd_do_query()ensures it is non-null. In addition the local variable query is already dereferenced by the time it is checked for null.
Quoted 9 lines
Remove the unneeded null check.
Signed-off-by Ira Weiny <[email protected]>---
Minor fix I found while working on the kernel side query command.
---
cxl/lib/libcxl.c | 3 ---1 file changed, 3 deletions(-)
Makes sense, applied, thanks!
Quoted 20 lines
cxl/lib/libcxl.c +0
-0@@ -3091,9 +3091,6 @@ static int cxl_cmd_alloc_send(struct cxl_cmd *cmd, u32 cmd_id) struct cxl_command_info *cinfo = &query->commands[cmd->query_idx]; size_t size;
- if (!query)
- return-EINVAL;
-
size =sizeof(struct cxl_send_command);
cmd->send_cmd =calloc(1, size);
if (!cmd->send_cmd)---
base-commit:b73e4e0390aae822bc91b8bf72430e6f0e84d668
change-id: 20230201-update_query-ad2845ba197aBest regards,