diff mbox series

cxl: Make loop variable be 'i' instead of 'j'

Message ID 20210226204552.45399-2-konrad.wilk@oracle.com
State Superseded
Headers show
Series cxl: Make loop variable be 'i' instead of 'j' | expand

Commit Message

Konrad Rzeszutek Wilk Feb. 26, 2021, 8:45 p.m. UTC
.. otherwise people spend extra cycles looking for the
inner loop and wondering 'why j'?

This was an over-sight when initial work was rebased
so lets fix it here.

Fixes: 583fa5e71cae ("cxl/mem: Add basic IOCTL interface")
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 drivers/cxl/mem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Dan Williams Feb. 26, 2021, 8:55 p.m. UTC | #1
On Fri, Feb 26, 2021 at 12:46 PM Konrad Rzeszutek Wilk
<konrad.wilk@oracle.com> wrote:
>

Hey, Konrad, thanks for fixing this up. Some more cosmetic changes to
fold in below...

> .. otherwise people spend extra cycles looking for the
> inner loop and wondering 'why j'?
>
> This was an over-sight when initial work was rebased

s/over-sight/oversight/

> so lets fix it here.

s/lets/let's/

> Fixes: 583fa5e71cae ("cxl/mem: Add basic IOCTL interface")

Since it's just cosmetic, I don't think it needs a "Fixes:". The
AUTOSEL-bot need not worry about this.

> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
>  drivers/cxl/mem.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
> index 244cb7d89678..2b8265b03b0d 100644
> --- a/drivers/cxl/mem.c
> +++ b/drivers/cxl/mem.c
> @@ -698,7 +698,7 @@ static int cxl_query_cmd(struct cxl_memdev *cxlmd,
>         struct device *dev = &cxlmd->dev;
>         struct cxl_mem_command *cmd;
>         u32 n_commands;
> -       int j = 0;
> +       int i = 0;

Let's move this initialization down to right before the loop. If this
ever gets refactored and @i gets reused this will break.

>
>         dev_dbg(dev, "Query IOCTL\n");
>
> @@ -716,10 +716,10 @@ static int cxl_query_cmd(struct cxl_memdev *cxlmd,
>         cxl_for_each_cmd(cmd) {
>                 const struct cxl_command_info *info = &cmd->info;
>
> -               if (copy_to_user(&q->commands[j++], info, sizeof(*info)))
> +               if (copy_to_user(&q->commands[i++], info, sizeof(*info)))
>                         return -EFAULT;
>
> -               if (j == n_commands)
> +               if (i == n_commands)
>                         break;
>         }
>
> --
> 2.13.6
>
Al Viro Feb. 26, 2021, 8:55 p.m. UTC | #2
On Fri, Feb 26, 2021 at 03:45:52PM -0500, Konrad Rzeszutek Wilk wrote:
> .. otherwise people spend extra cycles looking for the
> inner loop and wondering 'why j'?
> 
> This was an over-sight when initial work was rebased
> so lets fix it here.
> 
> Fixes: 583fa5e71cae ("cxl/mem: Add basic IOCTL interface")
  ^^^^^

34 days too early; otherwise, that's a damn good contender...
diff mbox series

Patch

diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c
index 244cb7d89678..2b8265b03b0d 100644
--- a/drivers/cxl/mem.c
+++ b/drivers/cxl/mem.c
@@ -698,7 +698,7 @@  static int cxl_query_cmd(struct cxl_memdev *cxlmd,
 	struct device *dev = &cxlmd->dev;
 	struct cxl_mem_command *cmd;
 	u32 n_commands;
-	int j = 0;
+	int i = 0;
 
 	dev_dbg(dev, "Query IOCTL\n");
 
@@ -716,10 +716,10 @@  static int cxl_query_cmd(struct cxl_memdev *cxlmd,
 	cxl_for_each_cmd(cmd) {
 		const struct cxl_command_info *info = &cmd->info;
 
-		if (copy_to_user(&q->commands[j++], info, sizeof(*info)))
+		if (copy_to_user(&q->commands[i++], info, sizeof(*info)))
 			return -EFAULT;
 
-		if (j == n_commands)
+		if (i == n_commands)
 			break;
 	}