git: a1295b24842d - main - linuxkpi: use canonical tests for is_{zero,broadcast}_ether_addr
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 08 Aug 2024 16:39:42 UTC
The branch main has been updated by emaste:
URL: https://cgit.FreeBSD.org/src/commit/?id=a1295b24842d209e6bf93a4823193d56ad2db064
commit a1295b24842d209e6bf93a4823193d56ad2db064
Author: Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-08-08 00:00:00 +0000
Commit: Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-08-08 16:39:14 +0000
linuxkpi: use canonical tests for is_{zero,broadcast}_ether_addr
They are functionally equivalent, but the updated form mirrors the tests
in sys/net/ethernet.h and avoids confusion.
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21037
---
sys/compat/linuxkpi/common/include/linux/etherdevice.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/etherdevice.h b/sys/compat/linuxkpi/common/include/linux/etherdevice.h
index 89cd4c8e0ba0..5d3df744ae0e 100644
--- a/sys/compat/linuxkpi/common/include/linux/etherdevice.h
+++ b/sys/compat/linuxkpi/common/include/linux/etherdevice.h
@@ -53,7 +53,8 @@ struct ethtool_modinfo {
static inline bool
is_zero_ether_addr(const u8 * addr)
{
- return ((addr[0] + addr[1] + addr[2] + addr[3] + addr[4] + addr[5]) == 0x00);
+ return ((addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]) ==
+ 0x00);
}
static inline bool
@@ -65,7 +66,8 @@ is_multicast_ether_addr(const u8 * addr)
static inline bool
is_broadcast_ether_addr(const u8 * addr)
{
- return ((addr[0] + addr[1] + addr[2] + addr[3] + addr[4] + addr[5]) == (6 * 0xff));
+ return ((addr[0] & addr[1] & addr[2] & addr[3] & addr[4] & addr[5]) ==
+ 0xff);
}
static inline bool