Skip to contentSkip to conversation

net/mlx4: && vs & typo

PATCH Applied Dan Carpenter 7 participants 8 messages Feb 28, 2017 – Mar 1, 2017 1 message not in the archive

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

PATCH 1/1 net/mlx4: && vs & typo

Bitwise & was obviously intended here.

Fixes 745d8ae4622c ("net/mlx4: Spoofcheck and zero MAC can't coexist")

---
Applies to net.git.

include/linux/mlx4/driver.h +1 -1
index e965e5090d96..a858bcb6220b 100644
@@ -109,7 +109,7 @@ static inline void mlx4_u64_to_mac(u8 *addr, u64 mac)
 	int i;
 
 	for (i = ETH_ALEN; i > 0; i--) {
-		addr[i - 1] = mac && 0xFF;
+		addr[i - 1] = mac & 0xFF;
 		mac >>= 8;
 	}
 }
#1 lore raw

T24gVHVlLCAyMDE3LTAyLTI4IGF0IDE1OjAyICswMzAwLCBEYW4gQ2FycGVudGVyIHdyb3RlOg0K PiBCaXR3aXNlICYgd2FzIG9idmlvdXNseSBpbnRlbmRlZCBoZXJlLg0KPiANCj4gRml4ZXM6IDc0 NWQ4YWU0NjIyYyAoIm5ldC9tbHg0OiBTcG9vZmNoZWNrIGFuZCB6ZXJvIE1BQyBjYW4ndCBjb2V4 aXN0IikNCj4gU2lnbmVkLW9mZi1ieTogRGFuIENhcnBlbnRlciA8ZGFuLmNhcnBlbnRlckBvcmFj bGUuY29tPg0KPiAtLS0NCj4gQXBwbGllcyB0byBuZXQuZ2l0Lg0KPiANCj4gZGlmZiAtLWdpdCBh L2luY2x1ZGUvbGludXgvbWx4NC9kcml2ZXIuaCBiL2luY2x1ZGUvbGludXgvbWx4NC9kcml2ZXIu aA0KPiBpbmRleCBlOTY1ZTUwOTBkOTYuLmE4NThiY2I2MjIwYiAxMDA2NDQNCj4gLS0tIGEvaW5j bHVkZS9saW51eC9tbHg0L2RyaXZlci5oDQo+ICsrKyBiL2luY2x1ZGUvbGludXgvbWx4NC9kcml2 ZXIuaA0KPiBAQCAtMTA5LDcgKzEwOSw3IEBAIHN0YXRpYyBpbmxpbmUgdm9pZCBtbHg0X3U2NF90 b19tYWModTggKmFkZHIsIHU2NCBtYWMpDQo+ICAJaW50IGk7DQo+ICANCj4gIAlmb3IgKGkgPSBF VEhfQUxFTjsgaSA+IDA7IGktLSkgew0KPiAtCQlhZGRyW2kgLSAxXSA9IG1hYyAmJiAweEZGOw0K PiArCQlhZGRyW2kgLSAxXSA9IG1hYyAmIDB4RkY7DQo+ICAJCW1hYyA+Pj0gODsNCj4gIAl9DQo+ ICB9DQoNCklzIHRoaXMgdGhlIG9ubHkgcGxhY2Ugd2hlcmUgc3VjaCBhIGxvb3Agb2NjdXJzPyBT aG91bGQgYSBwdXRfdW5hbGlnbmVkX2JlNDgoKQ0KZnVuY3Rpb24gYmUgaW50cm9kdWNlZD8NCg0K QmFydC4

Reviewed-by on v1 1/1
#7 lore raw
In reply to Dan Carpenter
Quoted 1 line · Dan Carpenter

Bitwise & was obviously intended here.

Sure! Thanks for your patch.

Quoted 20 lines
Fixes 745d8ae4622c ("net/mlx4: Spoofcheck and zero MAC can't coexist")

---
Applies to net.git.

include/linux/mlx4/driver.h +1 -2
index e965e5090d96..a858bcb6220b 100644
@@ -109,7 +109,7 @@ static inline void mlx4_u64_to_mac(u8 *addr, u64 mac)
 	int i;
 
 	for (i = ETH_ALEN; i > 0; i--) {
-		addr[i - 1] = mac && 0xFF;
+		addr[i - 1] = mac & 0xFF;
 		mac >>= 8;
 	}
 }
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to a message not in the archive
Quoted 2 lines · Bart Van Assche
Quoted 1 line · Dan Carpenter

Bitwise & was obviously intended here.

[]

Quoted 1 line

include/linux/mlx4/driver.h

Quoted 1 line
include/linux/mlx4/driver.h +0 -0

[]

Quoted 11 lines

include/linux/mlx4/driver.h static inline void (u8 *addr, u64 mac) · line 115

Quoted 9 lines
include/linux/mlx4/driver.h +1 -1
@@ -109,7 +109,7 @@ static inline void 	(u8 *addr, u64 mac)
 	int i;
 
 	for (i = ETH_ALEN; i > 0; i--) {
-		addr[i - 1] = mac && 0xFF;
+		addr[i - 1] = mac & 0xFF;
 		mac >>= 8;
 	}
 }

Is this the only place where such a loop occurs?

Seems to be.

Quoted 2 lines

Should a put_unaligned_be48()
function be introduced?

Why? This is used exactly once.

#4 lore raw
Quoted 18 lines · Joe Perches
Quoted 2 lines · Bart Van Assche
Quoted 1 line · Dan Carpenter

Bitwise & was obviously intended here.

[]

Quoted 1 line

include/linux/mlx4/driver.h

Quoted 1 line
include/linux/mlx4/driver.h +0 -0

[]

Quoted 11 lines

include/linux/mlx4/driver.h static inline void (u8 *addr, u64 mac) · line 115

Quoted 9 lines
include/linux/mlx4/driver.h +1 -1
@@ -109,7 +109,7 @@ static inline void 	(u8 *addr, u64 mac)
 	int i;
 
 	for (i = ETH_ALEN; i > 0; i--) {
-		addr[i - 1] = mac && 0xFF;
+		addr[i - 1] = mac & 0xFF;
 		mac >>= 8;
 	}
 }

Is this the only place where such a loop occurs?

Quoted 6 lines

Seems to be.

Quoted 2 lines

Should a put_unaligned_be48()
function be introduced?

Why? This is used exactly once.

Really? Here is an example of another open-coded version of put_unaligned_be48() from arch/mips/cavium-octeon/octeon-platform.c:

	new_mac[0] = (mac >> 40) & 0xff;
	new_mac[1] = (mac >> 32) & 0xff;
	new_mac[2] = (mac >> 24) & 0xff;
	new_mac[3] = (mac >> 16) & 0xff;
	new_mac[4] = (mac >> 8) & 0xff;
	new_mac[5] = mac & 0xff;

Bart.

#5 lore raw
Quoted 29 lines · Bart Van Assche
Quoted 18 lines · Joe Perches
Quoted 2 lines · Bart Van Assche
Quoted 1 line · Dan Carpenter

Bitwise & was obviously intended here.

[]

Quoted 1 line

include/linux/mlx4/driver.h

Quoted 1 line
include/linux/mlx4/driver.h +0 -0

[]

Quoted 11 lines

include/linux/mlx4/driver.h static inline void (u8 *addr, u64 mac) · line 115

Quoted 9 lines
include/linux/mlx4/driver.h +1 -1
@@ -109,7 +109,7 @@ static inline void 	(u8 *addr, u64 mac)
 	int i;
 
 	for (i = ETH_ALEN; i > 0; i--) {
-		addr[i - 1] = mac && 0xFF;
+		addr[i - 1] = mac & 0xFF;
 		mac >>= 8;
 	}
 }

Is this the only place where such a loop occurs?

Quoted 6 lines

Seems to be.

Quoted 2 lines

Should a put_unaligned_be48()
function be introduced?

Why? This is used exactly once.

Really? Here is an example of another open-coded version of put_unaligned_be48() from arch/mips/cavium-octeon/octeon-platform.c:

Quoted 6 lines
	new_mac[0] = (mac >> 40) & 0xff;
	new_mac[1] = (mac >> 32) & 0xff;
	new_mac[2] = (mac >> 24) & 0xff;
	new_mac[3] = (mac >> 16) & 0xff;
	new_mac[4] = (mac >> 8) & 0xff;
	new_mac[5] = mac & 0xff;

drivers/media/radio/radio-shark2.c:

        for (i = 0; i < 6; i++)
               shark->transfer_buffer[i + 1] = (reg >> (40 - i * 8)) & 0xff;

drivers/rtc/rtc-ab3100.c

       buf[0] = (hw_counter) & 0xFF;
       buf[1] = (hw_counter >> 8) & 0xFF;
       buf[2] = (hw_counter >> 16) & 0xFF;
       buf[3] = (hw_counter >> 24) & 0xFF;
       buf[4] = (hw_counter >> 32) & 0xFF;
       buf[5] = (hw_counter >> 40) & 0xFF;

drivers/net/ethernet/sun/ldmvsw.c

        for (i = 0; i < ETH_ALEN; i++)
               port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff;

drivers/net/ethernet/sun/sunvnet.c

        for (i = 0; i < ETH_ALEN; i++)
               dev->dev_addr[i] = (*local_mac >> (5 - i) * 8) & 0xff;

        for (i = 0; i < ETH_ALEN; i++)
               port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff;

julia

Quoted 7 lines

Bart.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 54 lines · Julia Lawall
Quoted 29 lines · Bart Van Assche
Quoted 18 lines · Joe Perches
Quoted 2 lines · Bart Van Assche
Quoted 1 line · Dan Carpenter

Bitwise & was obviously intended here.

[]

Quoted 1 line

include/linux/mlx4/driver.h

Quoted 1 line
include/linux/mlx4/driver.h +0 -0

[]

Quoted 11 lines

include/linux/mlx4/driver.h static inline void (u8 *addr, u64 mac) · line 115

Quoted 9 lines
include/linux/mlx4/driver.h +1 -1
@@ -109,7 +109,7 @@ static inline void 	(u8 *addr, u64 mac)
 	int i;
 
 	for (i = ETH_ALEN; i > 0; i--) {
-		addr[i - 1] = mac && 0xFF;
+		addr[i - 1] = mac & 0xFF;
 		mac >>= 8;
 	}
 }

Is this the only place where such a loop occurs?

Quoted 6 lines

Seems to be.

Quoted 2 lines

Should a put_unaligned_be48()
function be introduced?

Why? This is used exactly once.

Really? Here is an example of another open-coded version of put_unaligned_be48() from arch/mips/cavium-octeon/octeon-platform.c:

Quoted 6 lines
	new_mac[0] = (mac >> 40) & 0xff;
	new_mac[1] = (mac >> 32) & 0xff;
	new_mac[2] = (mac >> 24) & 0xff;
	new_mac[3] = (mac >> 16) & 0xff;
	new_mac[4] = (mac >> 8) & 0xff;
	new_mac[5] = mac & 0xff;

drivers/media/radio/radio-shark2.c:

        for (i = 0; i < 6; i++)
               shark->transfer_buffer[i + 1] = (reg >> (40 - i * 8)) & 0xff;

drivers/rtc/rtc-ab3100.c

       buf[0] = (hw_counter) & 0xFF;
       buf[1] = (hw_counter >> 8) & 0xFF;
       buf[2] = (hw_counter >> 16) & 0xFF;
       buf[3] = (hw_counter >> 24) & 0xFF;
       buf[4] = (hw_counter >> 32) & 0xFF;
       buf[5] = (hw_counter >> 40) & 0xFF;

drivers/net/ethernet/sun/ldmvsw.c

        for (i = 0; i < ETH_ALEN; i++)
               port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff;
Quoted 9 lines

drivers/net/ethernet/sun/sunvnet.c

        for (i = 0; i < ETH_ALEN; i++)
               dev->dev_addr[i] = (*local_mac >> (5 - i) * 8) & 0xff;

        for (i = 0; i < ETH_ALEN; i++)
               port->raddr[i] = (*rmac >> (5 - i) * 8) & 0xff;

julia

With these code replication examples, I agree that a function should be introduced.

Quoted 12 lines
Quoted 7 lines

Bart.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html