-
Notifications
You must be signed in to change notification settings - Fork 221
Description
Hi,
I work at Intel, and we have developed a tool, named ControlFlag, that detects anomalous programming language expressions that can possibly lead to bugs. We scanned the code repository for this project, and we found a couple of places where the code/expressions are confusing and seem to implement the logic in a rather convoluted manner. We think that the expressions could be rewritten to capture the logic accurately and precisely.
Case 1) Expression (l_inbuf[2] | 1)
in the following code seems confusing because it would always evaluate to true
as per C language. Was the intention to say (l_inbuf[2] & 1)
? This is in line 108 below
Lines 108 to 113 in c8465be
if (l_inbuf[2] | 1) //right or left glove | |
{ | |
VRPN_MSG_WARNING ("A right glove is ready"); | |
} else { | |
VRPN_MSG_WARNING ("A left glove is ready"); | |
} |
Case 2) Similarly, expression if (l_inbuf[3] | 1)
seems confusing. Was the intention to say if (l_inbuf[3] & 1)
? This is in line 114 below
Lines 114 to 119 in c8465be
if (l_inbuf[3] | 1) //wireless glove or wired | |
{ | |
VRPN_MSG_WARNING ("no wireless glove"); | |
} else { | |
VRPN_MSG_WARNING ("wireless glove"); | |
} |
Case 3) Similarly, expression if (l_inbuf[4] | 1)
seems confusing for the same reason. This is in line 194 below
Lines 194 to 198 in c8465be
if (l_inbuf[4] | 1) { | |
VRPN_MSG_INFO ("A right glove is ready"); | |
} else { | |
VRPN_MSG_INFO ("A left glove is ready"); | |
} |
Case 4) For the same reason, expression if (l_inbuf[5] | 16)
in line 199 look confusing.
Lines 199 to 203 in c8465be
if (l_inbuf[5] | 16) { | |
VRPN_MSG_INFO ("Pitch and Roll are available"); | |
} else { | |
VRPN_MSG_INFO ("Pitch and Roll are not available"); | |
} |
I would be happy to fix these issues, if someone can confirm them as bugs.