All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH ndctl] ndctl/cxl: Remove unnecessary null check
@ 2023-02-03 21:56 Ira Weiny
  2023-02-03 22:30 ` Dave Jiang
  2023-02-03 23:07 ` Verma, Vishal L
  0 siblings, 2 replies; 3+ messages in thread
From: Ira Weiny @ 2023-02-03 21:56 UTC (permalink / raw)
  To: Vishal Verma; +Cc: linux-cxl, Ira Weiny

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.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Minor fix I found while working on the kernel side query command.
---
 cxl/lib/libcxl.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index 4205a587d3bb..4859bd5e2fbb 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -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,
-- 
Ira Weiny <ira.weiny@intel.com>

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH ndctl] ndctl/cxl: Remove unnecessary null check
  2023-02-03 21:56 [PATCH ndctl] ndctl/cxl: Remove unnecessary null check Ira Weiny
@ 2023-02-03 22:30 ` Dave Jiang
  2023-02-03 23:07 ` Verma, Vishal L
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2023-02-03 22:30 UTC (permalink / raw)
  To: Ira Weiny, Vishal Verma; +Cc: linux-cxl



On 2/3/23 2:56 PM, Ira Weiny wrote:
> 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.
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
> Minor fix I found while working on the kernel side query command.
> ---
>   cxl/lib/libcxl.c | 3 ---
>   1 file changed, 3 deletions(-)
> 
> diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
> index 4205a587d3bb..4859bd5e2fbb 100644
> --- a/cxl/lib/libcxl.c
> +++ b/cxl/lib/libcxl.c
> @@ -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,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH ndctl] ndctl/cxl: Remove unnecessary null check
  2023-02-03 21:56 [PATCH ndctl] ndctl/cxl: Remove unnecessary null check Ira Weiny
  2023-02-03 22:30 ` Dave Jiang
@ 2023-02-03 23:07 ` Verma, Vishal L
  1 sibling, 0 replies; 3+ messages in thread
From: Verma, Vishal L @ 2023-02-03 23:07 UTC (permalink / raw)
  To: Weiny, Ira; +Cc: linux-cxl

On Fri, 2023-02-03 at 13:56 -0800, Ira Weiny wrote:
> 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.
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
> 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!

> diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
> index 4205a587d3bb..4859bd5e2fbb 100644
> --- a/cxl/lib/libcxl.c
> +++ b/cxl/lib/libcxl.c
> @@ -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,


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-03 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 21:56 [PATCH ndctl] ndctl/cxl: Remove unnecessary null check Ira Weiny
2023-02-03 22:30 ` Dave Jiang
2023-02-03 23:07 ` Verma, Vishal L

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.