From: Dave Jiang <dave.jiang@intel.com>
To: Alison Schofield <alison.schofield@intel.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Jonathan Cameron <jic23@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Ira Weiny <iweiny@kernel.org>, Dan Williams <djbw@kernel.org>,
Li Ming <ming.li@zohomail.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH] cxl/region: Avoid variable shadowing in region attach paths
Date: Tue, 9 Jun 2026 11:01:20 -0700 [thread overview]
Message-ID: <40cee466-729a-467d-b93e-43c6f5057dfd@intel.com> (raw)
In-Reply-To: <20260605040504.865728-1-alison.schofield@intel.com>
On 6/4/26 9:05 PM, Alison Schofield wrote:
> A couple of symbol declarations shadow earlier variables in the region
> attach paths. Shadowing makes it harder to tell which object is being
> referenced and can obscure future bugs.
>
> Reuse the existing 'cxld' variable in cxl_port_attach_region() and
> rename the endpoint decoder iterator in cxl_region_attach() to avoid
> shadowing the function parameter.
>
> No functional change.
>
> Found with sparse.
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Applied to cxl/next
1e1edc973c64307821ee22049908e7ded8f973c2
> ---
> drivers/cxl/core/region.c | 14 ++++++--------
> 1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index e50dc716d4e8..819392c8f753 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -1224,8 +1224,6 @@ static int cxl_port_attach_region(struct cxl_port *port,
> nr_targets_inc = true;
> }
> } else {
> - struct cxl_decoder *cxld;
> -
> cxld = cxl_port_pick_region_decoder(port, cxled, cxlr);
> if (!cxld) {
> dev_dbg(&cxlr->dev, "%s: no decoder available\n",
> @@ -2189,14 +2187,14 @@ static int cxl_region_attach(struct cxl_region *cxlr,
> * will fail when presented as CXL_REGION_F_AUTO.
> */
> for (int i = 0; i < p->nr_targets; i++) {
> - struct cxl_endpoint_decoder *cxled = p->targets[i];
> + struct cxl_endpoint_decoder *target = p->targets[i];
> int test_pos;
>
> - test_pos = cxl_calc_interleave_pos(cxled, &cxlr->hpa_range);
> - dev_dbg(&cxled->cxld.dev,
> - "Test cxl_calc_interleave_pos(): %s test_pos:%d cxled->pos:%d\n",
> - (test_pos == cxled->pos) ? "success" : "fail",
> - test_pos, cxled->pos);
> + test_pos = cxl_calc_interleave_pos(target, &cxlr->hpa_range);
> + dev_dbg(&target->cxld.dev,
> + "Test cxl_calc_interleave_pos(): %s test_pos:%d target->pos:%d\n",
> + (test_pos == target->pos) ? "success" : "fail",
> + test_pos, target->pos);
> }
>
> return 0;
>
> base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
prev parent reply other threads:[~2026-06-09 18:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 4:05 [PATCH] cxl/region: Avoid variable shadowing in region attach paths Alison Schofield
2026-06-05 15:38 ` Dave Jiang
2026-06-05 15:59 ` Li Ming
2026-06-09 18:01 ` Dave Jiang [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=40cee466-729a-467d-b93e-43c6f5057dfd@intel.com \
--to=dave.jiang@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=ming.li@zohomail.com \
--cc=vishal.l.verma@intel.com \
/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