From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Weiny, Ira" <ira.weiny@intel.com>
Cc: "linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>
Subject: Re: [PATCH ndctl] ndctl/cxl: Remove unnecessary null check
Date: Fri, 3 Feb 2023 23:07:29 +0000 [thread overview]
Message-ID: <2c861e6cc1ec27d016d66c98affb6def552fb800.camel@intel.com> (raw)
In-Reply-To: <20230201-update_query-v1-1-4dd3de2d35c1@intel.com>
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,
prev parent reply other threads:[~2023-02-03 23:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c861e6cc1ec27d016d66c98affb6def552fb800.camel@intel.com \
--to=vishal.l.verma@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox