Linux MultiMedia Card development
 help / color / mirror / Atom feed
From: Bean Huo <beanhuo@iokpp.de>
To: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org,
	jens.wiklander@linaro.org, Avri.Altman@sandisk.com
Cc: Bean Huo <beanhuo@micron.com>, Avri Altman <avri.altman@sandisk.com>
Subject: [PATCH v3 1/2] mmc: core: Fix variable shadowing in mmc_route_rpmb_frames()
Date: Thu, 11 Sep 2025 23:06:05 +0200	[thread overview]
Message-ID: <20250911210606.446355-2-beanhuo@iokpp.de> (raw)
In-Reply-To: <20250911210606.446355-1-beanhuo@iokpp.de>

From: Bean Huo <beanhuo@micron.com>

Rename the inner 'frm' variable to 'resp_frm' in the write path of
mmc_route_rpmb_frames() to avoid shadowing the outer 'frm' variable.

The function declares 'frm' at function scope pointing to the request
frame, but then redeclares another 'frm' variable inside the write
block pointing to the response frame. This shadowing makes the code
confusing and error-prone.

Using 'resp_frm' for the response frame makes the distinction clear
and improves code readability.

Fixes: 7852028a35f0 ("mmc: block: register RPMB partition with the RPMB subsystem")
Reviewed-by: Avri Altman <avri.altman@sandisk.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/mmc/core/block.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 9cc47bf94804..dd6cffc0df72 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2936,15 +2936,15 @@ static int mmc_route_rpmb_frames(struct device *dev, u8 *req,
 		return -ENOMEM;
 
 	if (write) {
-		struct rpmb_frame *frm = (struct rpmb_frame *)resp;
+		struct rpmb_frame *resp_frm = (struct rpmb_frame *)resp;
 
 		/* Send write request frame(s) */
 		set_idata(idata[0], MMC_WRITE_MULTIPLE_BLOCK,
 			  1 | MMC_CMD23_ARG_REL_WR, req, req_len);
 
 		/* Send result request frame */
-		memset(frm, 0, sizeof(*frm));
-		frm->req_resp = cpu_to_be16(RPMB_RESULT_READ);
+		memset(resp_frm, 0, sizeof(*resp_frm));
+		resp_frm->req_resp = cpu_to_be16(RPMB_RESULT_READ);
 		set_idata(idata[1], MMC_WRITE_MULTIPLE_BLOCK, 1, resp,
 			  resp_len);
 
-- 
2.34.1


  reply	other threads:[~2025-09-11 21:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 21:06 [PATCH v3 0/2] mmc: core: RPMB code improvements Bean Huo
2025-09-11 21:06 ` Bean Huo [this message]
2025-09-11 21:06 ` [PATCH v3 2/2] mmc: core: Improve RPMB frame handling code Bean Huo
2025-09-12 12:26   ` Avri Altman
2025-09-12 13:34 ` [PATCH v3 0/2] mmc: core: RPMB code improvements Ulf Hansson
2025-09-12 14:58   ` Bean Huo

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=20250911210606.446355-2-beanhuo@iokpp.de \
    --to=beanhuo@iokpp.de \
    --cc=Avri.Altman@sandisk.com \
    --cc=beanhuo@micron.com \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.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