Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Aug 2024 23:04:20 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f8a439c53840 - stable/13 - linuxkpi: use canonical tests for is_{zero,broadcast}_ether_addr
Message-ID:  <202408112304.47BN4Ka4032624@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=f8a439c538400f6ca67cbff71b98c29320a2ebf6

commit f8a439c538400f6ca67cbff71b98c29320a2ebf6
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-08-08 00:00:00 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-08-11 23:03:42 +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
    
    (cherry picked from commit a1295b24842d209e6bf93a4823193d56ad2db064)
    (cherry picked from commit 6fb0634bc4ce5fe32312a53031e56fe866b0b24d)
---
 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202408112304.47BN4Ka4032624>