[PATCH] i2c: bcm2835: add missing braces to for loop in bcm2835_i2c_xfer

zhaohaiyang1 posted 1 patch 1 month, 1 week ago
drivers/i2c/busses/i2c-bcm2835.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] i2c: bcm2835: add missing braces to for loop in bcm2835_i2c_xfer
Posted by zhaohaiyang1 1 month, 1 week ago
From: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>

Add curly braces around the multi-statement body of the for loop
that checks for unsupported read messages. This fixes a coding
style issue where the compound statement lacked explicit braces.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
---
 drivers/i2c/busses/i2c-bcm2835.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 8554e790f8e3..76d017cf1582 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -349,12 +349,13 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 	unsigned long time_left;
 	int i;
 
-	for (i = 0; i < (num - 1); i++)
+	for (i = 0; i < (num - 1); i++) {
 		if (msgs[i].flags & I2C_M_RD) {
 			dev_warn_once(i2c_dev->dev,
 				      "only one read message supported, has to be last\n");
 			return -EOPNOTSUPP;
 		}
+	}
 
 	i2c_dev->curr_msg = msgs;
 	i2c_dev->num_msgs = num;
-- 
2.43.0
Re: [PATCH] i2c: bcm2835: add missing braces to for loop in bcm2835_i2c_xfer
Posted by Andi Shyti 1 month, 1 week ago
Hi,

On Mon, Aug 17, 2026 at 09:02:34PM +0800, zhaohaiyang1 wrote:
> From: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
> 
> Add curly braces around the multi-statement body of the for loop
> that checks for unsupported read messages. This fixes a coding
> style issue where the compound statement lacked explicit braces.

it's not a multi statement body, if you look very carefully from
closer, there is only one single solitary 'if' statement.

> Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>

Please next time use your real name here.

Thanks,
Andi

> ---
>  drivers/i2c/busses/i2c-bcm2835.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
> index 8554e790f8e3..76d017cf1582 100644
> --- a/drivers/i2c/busses/i2c-bcm2835.c
> +++ b/drivers/i2c/busses/i2c-bcm2835.c
> @@ -349,12 +349,13 @@ static int bcm2835_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
>  	unsigned long time_left;
>  	int i;
>  
> -	for (i = 0; i < (num - 1); i++)
> +	for (i = 0; i < (num - 1); i++) {
>  		if (msgs[i].flags & I2C_M_RD) {
>  			dev_warn_once(i2c_dev->dev,
>  				      "only one read message supported, has to be last\n");
>  			return -EOPNOTSUPP;
>  		}
> +	}
>  
>  	i2c_dev->curr_msg = msgs;
>  	i2c_dev->num_msgs = num;
> -- 
> 2.43.0
>