Skip to contentSkip to conversation

Staging: iio: adc: Replace memset with eth_broadcast_addr

PATCH In review Bhumika Goyal 2 participants 2 messages Mar 1, 2016 – Mar 11, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: iio: adc: Replace memset with eth_broadcast_addr

Use eth_broadcast_addr to assign the broadcast address to the given address array instead of memset when the second argument is a broacast address 0xff. ETH_ALEN is a macro with value 6, so 6 is treated as ETH_ALEN if it is the third argument of memset.

Done using coccinelle.
@@
expression e;
@@
- memset(e,\(0xff\|0xFF\|255\),\(ETH_ALEN\|6\));
+ eth_broadcast_addr(e);

---
 drivers/staging/iio/adc/ad7192.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7192.c +1 -1
index 1e85657..c2b5d21 100644
@@ -225,7 +225,7 @@ static int ad7192_setup(struct ad7192_state *st,
 	u8 ones[6];
 
 	/* reset the serial interface */
-	memset(&ones, 0xFF, 6);
+	eth_broadcast_addr(&ones);
 	ret = spi_write(st->sd.spi, &ones, 6);
 	if (ret < 0)
 		goto out;
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 22 lines · Bhumika Goyal

Use eth_broadcast_addr to assign the broadcast address to the given address array instead of memset when the second argument is a broacast address 0xff. ETH_ALEN is a macro with value 6, so 6 is treated as ETH_ALEN if it is the third argument of memset.

Done using coccinelle.
@@
expression e;
@@
- memset(e,\(0xff\|0xFF\|255\),\(ETH_ALEN\|6\));
+ eth_broadcast_addr(e);

---
 drivers/staging/iio/adc/ad7192.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7192.c +0 -0
index 1e85657..c2b5d21 100644

drivers/staging/iio/adc/ad7192.c static int ad7192_setup(struct ad7192_state *st, · line 231

Quoted 8 lines
drivers/staging/iio/adc/ad7192.c +1 -1
@@ -225,7 +225,7 @@ static int ad7192_setup(struct ad7192_state *st,
 	u8 ones[6];
 
 	/* reset the serial interface */
-	memset(&ones, 0xFF, 6);
+	eth_broadcast_addr(&ones);
 	ret = spi_write(st->sd.spi, &ones, 6);
 	if (ret < 0)
 		goto out;

You didn't test build this change :(