cxl/region: Avoid variable shadowing in region attach paths
Alison Schofield
maintainerPATCH 1/1 cxl/region: Avoid variable shadowing in region attach paths
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.
--- drivers/cxl/core/region.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/cxl/core/region.c +6 -8
@@ -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
Signature · 1 line
2.37.3
Quoted 8 lines · Alison Schofield
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 incxl_region_attach()to avoid shadowing the function parameter.
Quoted 5 lines
No functional change.
Found with sparse.
Signed-off-by Alison Schofield <[email protected]>
Quoted 40 lines
--- drivers/cxl/core/region.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/cxl/core/region.c +6
-8@@ -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
Quoted 8 lines · Alison Schofield
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 incxl_region_attach()to avoid shadowing the function parameter.
Quoted 5 lines
No functional change.
Found with sparse.
Signed-off-by Alison Schofield <[email protected]>
Quoted 8 lines · Alison Schofield
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 incxl_region_attach()to avoid shadowing the function parameter.
Quoted 5 lines
No functional change.
Found with sparse.
Signed-off-by Alison Schofield <[email protected]>
Applied to cxl/next1e1edc973c64307821ee22049908e7ded8f973c2
Quoted 40 lines
--- drivers/cxl/core/region.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/cxl/core/region.c +6
-8@@ -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