Skip to contentSkip to conversation

rtl2832.c: minor cleanup

PATCH In review Hans-Frieder Vogt 2 participants 2 messages Jul 15, 2012 – Jul 23, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtl2832.c: minor cleanup

The current formulation of the bw_params loop uses the counter j as an index for the first dimension of the bw_params array which is later incremented by the variable i.
It is evaluated correctly only, because j is initialized to 0 at the beginning of the loop. I think that explicitly using the index 0 better reflects the intent of the expression.

 rtl2832.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb/frontends/rtl2832.c +1 -1
@@ -589,7 +589,7 @@ static int rtl2832_set_frontend(struct d
 		return -EINVAL;
 	}
 
-	for (j = 0; j < sizeof(bw_params[j]); j++) {
+	for (j = 0; j < sizeof(bw_params[0]); j++) {
 		ret = rtl2832_wr_regs(priv, 0x1c+j, 1, &bw_params[i][j], 1);
 		if (ret)
 			goto err;

Hans-Frieder Vogt e-mail: hfvogt <at> gmx .dot. net

#1 lore raw
Quoted 4 lines · Hans-Frieder Vogt

The current formulation of the bw_params loop uses the counter j as an index for the first dimension of the bw_params array which is later incremented by the variable i.
It is evaluated correctly only, because j is initialized to 0 at the beginning of the loop. I think that explicitly using the index 0 better reflects the intent of the expression.

You are right. It makes the code more readeable.

Quoted 20 lines
 rtl2832.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb/frontends/rtl2832.c +1 -1
@@ -589,7 +589,7 @@ static int rtl2832_set_frontend(struct d
 		return -EINVAL;
 	}
 
-	for (j = 0; j < sizeof(bw_params[j]); j++) {
+	for (j = 0; j < sizeof(bw_params[0]); j++) {
 		ret = rtl2832_wr_regs(priv, 0x1c+j, 1, &bw_params[i][j], 1);
 		if (ret)
 			goto err;

Hans-Frieder Vogt e-mail: hfvogt <at> gmx .dot. net