Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Use of logical '&&' with constant operand #148

Closed
rubienr opened this issue Nov 16, 2020 · 3 comments · Fixed by #155
Closed

Use of logical '&&' with constant operand #148

rubienr opened this issue Nov 16, 2020 · 3 comments · Fixed by #155
Labels
fixed Issue is fixed

Comments

@rubienr
Copy link

rubienr commented Nov 16, 2020

Multiple usages of logical && with constant operand for example imuMeas.dataType[i] = (bitField && 0xFF000000) >> 23 in:

imuMeas.xAngRateVald = (validity && 0x0080) >> 8;

uint8_t timeSent = (flags && 0x01) >> 1;

imuMeas.dataType[i] = (bitField && 0xFF000000) >> 23;

imuMeas.rawDataType = (bitField && 0xFF000000) >> 23;

ubloxSen.senType = (sensorFieldOne && 0x10) >> 5;

@PaulZC
Copy link
Collaborator

PaulZC commented Nov 17, 2020

Many thanks @rubienr for spotting this! Yes, they should be bitwise ANDs (&).
@edspark - just copying you in so you are aware. I'll change this in the release_candidate branch ready for the next release.
Thanks again,
Paul

@PaulZC
Copy link
Collaborator

PaulZC commented Nov 17, 2020

Hi @rubienr & @edspark ,
@rubienr : thank you again for spotting this!
I have corrected the ANDs (and some of the bit masks) in this commit.
@edspark : can you please review the changes - and test if possible? I don't have a dead-reckoning module here to test them on... :-( Thanks!
Best wishes,
Paul

@rubienr
Copy link
Author

rubienr commented Nov 17, 2020

Hi,

I am at a very early stage with my project development and my prototype is stationary for the moment. Thus I cannot meningfully test dead-reckoning. However I switched my dependency to the RC branch. Will keep you posted if I find issues related to this commit.

I tried to compile with -Wall -Werror and for this the unused variables would need to be uncommented (sorry for being off topic in this thread):

uint16_t refStationID = extractInt(2);

uint32_t timeStamp = extractLong(0);

uint8_t timeSent = flags & 0x03; // timeSent is 2-bit: 0 = none, 1 = on Ext0, 2 = on Ext1

uint8_t timeEdge = (flags & 0x04) >> 2;

uint8_t tagValid = (flags & 0x08) >> 3;

@PaulZC PaulZC added the fixed Issue is fixed label Nov 30, 2020
@PaulZC PaulZC linked a pull request Dec 1, 2020 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed Issue is fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants