Skip to content

Commit

Permalink
Fix #384: properly parenthesize mask comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
terrillmoore committed Aug 24, 2019
1 parent 1fe1a9a commit 3f06760
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lmic/lmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ applyAdrRequests(
LMICbandplan_saveAdrState(&initialState);

// compute the changes
if (adrAns == MCMD_LinkADRAns_PowerACK | MCMD_LinkADRAns_DataRateACK | MCMD_LinkADRAns_ChannelACK) {
if (adrAns == (MCMD_LinkADRAns_PowerACK | MCMD_LinkADRAns_DataRateACK | MCMD_LinkADRAns_ChannelACK)) {
for (oidx = 0; oidx < olen; oidx += kAdrReqSize) {
// can we advance?
if (olen - oidx < kAdrReqSize) {
Expand Down Expand Up @@ -990,7 +990,7 @@ scan_mac_cmds(
ans &= ~MCMD_NewChannelAns_DataRateACK;
}

if( ans == MCMD_NewChannelAns_DataRateACK|MCMD_NewChannelAns_ChannelACK) {
if( ans == (MCMD_NewChannelAns_DataRateACK|MCMD_NewChannelAns_ChannelACK)) {
if ( ! LMIC_setupChannel(chidx, freq, DR_RANGE_MAP(MinDR, MaxDR), -1) ) {
LMICOS_logEventUint32("NewChannelReq: setupChannel failed", (MaxDR << 24u) | (MinDR << 16u) | (raw_f_not_zero << 8) | (chidx << 0));
ans &= ~MCMD_NewChannelAns_ChannelACK;
Expand Down Expand Up @@ -1019,7 +1019,7 @@ scan_mac_cmds(
ans &= ~MCMD_DlChannelAns_FreqACK;
}

if( ans == MCMD_DlChannelAns_FreqACK|MCMD_DlChannelAns_ChannelACK) {
if( ans == (MCMD_DlChannelAns_FreqACK|MCMD_DlChannelAns_ChannelACK)) {
LMIC.channelDlFreq[chidx] = freq;
}

Expand All @@ -1044,7 +1044,7 @@ scan_mac_cmds(
if (! validDR(dr))
ans &= ~MCMD_PingSlotFreqAns_DataRateACK;

if (ans == MCMD_PingSlotFreqAns_DataRateACK|MCMD_PingSlotFreqAns_ChannelACK) {
if (ans == (MCMD_PingSlotFreqAns_DataRateACK|MCMD_PingSlotFreqAns_ChannelACK)) {
LMIC.ping.freq = freq;
LMIC.ping.dr = dr;
DO_DEVDB(LMIC.ping.intvExp, pingIntvExp);
Expand Down

0 comments on commit 3f06760

Please sign in to comment.