ieee802154: add extended address validation helper
Hello Alexander Aring,
The patch cb904b0a1630: "ieee802154: add extended address validation helper" from Nov 2, 2014, leads to the following static checker warning:
include/linux/ieee802154.h:212 ieee802154_is_valid_extended_addr() warn: was && intended here instead of ||?
include/linux/ieee802154.h
201 /**
202 * ieee802154_is_valid_psdu_len - check if extended addr is valid
203 * @addr: extended addr to check
204 */
205 static inline bool ieee802154_is_valid_extended_addr(const __le64 addr)
206 {
207 /* These EUI-64 addresses are reserved by IEEE. 0xffffffffffffffff
208 * is used internally as extended to short address broadcast mapping.
209 * This is currently a workaround because neighbor discovery can't
210 * deal with short addresses types right now.
211 */ 212 return ((addr != cpu_to_le64(0x0000000000000000ULL)) ||
213 (addr != cpu_to_le64(0xffffffffffffffffULL)));
The current code always returns true. It looks like the static checker suggestion of change || to && is the correct fix?
214 }
regards,
dan carpenter
Alexander Aring
maintainerHi Dan Carpenter,
Quoted 21 lines · Dan Carpenter
Hello Alexander Aring,
The patch
cb904b0a1630: "ieee802154: add extended address validation helper" from Nov 2, 2014, leads to the following static checker warning:include/linux/ieee802154.h:212 ieee802154_is_valid_extended_addr() warn: was && intended here instead of ||?
include/linux/ieee802154.h
201 /**202 * ieee802154_is_valid_psdu_len - check if extended addr is valid 203 * @addr: extended addr to check 204 */ 205 static inline bool ieee802154_is_valid_extended_addr(const __le64 addr) 206 { 207 /* These EUI-64 addresses are reserved by IEEE. 0xffffffffffffffff 208 * is used internally as extended to short address broadcast mapping. 209 * This is currently a workaround because neighbor discovery can't 210 * deal with short addresses types right now. 211 */
Quoted 6 lines
212 return ((addr !=
cpu_to_le64(0x0000000000000000ULL)) ||
213 (addr !=cpu_to_le64(0xffffffffffffffffULL)));The current code always returns true. It looks like the static checker suggestion of change || to && is the correct fix?
yes, you are right. Thanks for the suggestion. Do you want to fix that and send a patch based on bluetooth-next or should I queue this for my next series?
- Alex
PATCH 1/1 ieee802154: || vs && in ieee802154_is_valid_extended_addr()
The ieee802154_is_valid_extended_addr() always returns true because there is a typo. The || should be &&. Neither 0x0000000000000000ULL nor 0xffffffffffffffffULL are valid addresses.
include/linux/ieee802154.h +1 -1
@@ -209,7 +209,7 @@ static inline bool ieee802154_is_valid_extended_addr(const __le64 addr)* This is currently a workaround because neighbor discovery can't * deal with short addresses types right now. */ -return ((addr !=cpu_to_le64 (0x0000000000000000ULL )) || +return ((addr !=cpu_to_le64 (0x0000000000000000ULL )) && (addr !=cpu_to_le64 (0xffffffffffffffffULL ))); }
Re: [patch] ieee802154: || vs && in ieee802154_is_valid_extended_addr()
Quoted 5 lines · Dan Carpenter
The
ieee802154_is_valid_extended_addr()always returns true because there is a typo. The || should be &&. Neither0x0000000000000000ULLnor0xffffffffffffffffULLare valid addresses.Signed-off-by Dan Carpenter <[email protected]>
Re: [patch] ieee802154: || vs && in ieee802154_is_valid_extended_addr()
In reply to Dan CarpenterHi Dan,
Quoted 5 lines
The
ieee802154_is_valid_extended_addr()always returns true because there is a typo. The || should be &&. Neither0x0000000000000000ULLnor0xffffffffffffffffULLare valid addresses.Signed-off-by Dan Carpenter <[email protected]>
patch has been applied to bluetooth-next tree.
Regards
Marcel