Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core/net/mac/frame802154: Fix typo in PAN ID compression condition #1723

Merged

Conversation

jnohlgard
Copy link
Contributor

I stumbled upon this warning when trying out the new GCC 6.1 release:

../../../contiki/core/net/mac/frame802154.c: In function ‘frame802154_has_panid’:
../../../contiki/core/net/mac/frame802154.c:151:30: warning: self-comparison always evaluates to true [-Wtautological-compare]
       if(fcf->dest_addr_mode == fcf->dest_addr_mode) {
                              ^~

I believe this is a typo and that the correct fix is the supplied PR, but please validate this independently.

@simonduq
Copy link
Member

I confirm this is a bug, and not the only one. It is something I had seen and fixed before but forgot to upstream it seems.

I think the test should be:
if((fcf->dest_addr_mode == 0) == (fcf->src_addr_mode == 0)) {
(because we don't want equality, we only want both 0 or both non-0)

Then, the next if if(fcf->dest_addr_mode == 0 && fcf->dest_addr_mode == 1) { should basically be removed together with its content.

The third one should also become:
if(fcf->dest_addr_mode == 0 && fcf->src_addr_mode == 0) {

@jnohlgard
Copy link
Contributor Author

I rewrote the conditions based on table 2a in IEEE 802.15.4e-2012

dest_pan_id = 1;
} else if(fcf->src_addr_mode) {
/* Only src address, include src PAN ID */
src_pan_id = 1;
}
}
if(fcf->dest_addr_mode == 0 && fcf->dest_addr_mode == 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition could never be true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right this needs removing as mentioned in my previous comment

@simonduq
Copy link
Member

👍

@jnohlgard
Copy link
Contributor Author

OK to squash?

@alignan
Copy link
Member

alignan commented Jul 4, 2016

Yes, please do

@jnohlgard jnohlgard force-pushed the pr/ieee802154-addr-mode-bugfix branch from 55f6aee to 6f8306a Compare July 4, 2016 16:19
@jnohlgard
Copy link
Contributor Author

squashed

@simonduq
Copy link
Member

simonduq commented Jul 4, 2016

Thanks!

@simonduq simonduq merged commit 80b9bfe into contiki-os:master Jul 5, 2016
@jnohlgard jnohlgard deleted the pr/ieee802154-addr-mode-bugfix branch October 3, 2016 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants