The three new complaints about "Assign instead of compare" in pike_tokenizer looks very, very intentional, but I'll leave it up to whoever introduced them (grubba?) to mark them as false positives.
Reports for context, I'm considering sending these directly to the list since new reports a rather rare. Opinions?
New defect(s) Reported-by: Coverity Scan Showing 3 of 3 defect(s)
** CID 1317354: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) /home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike_tokenizer.h: 237 in ()
_____________________________________________________________________ *** CID 1317354: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) /home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike_tokenizer.h: 237 in () 231 break; 232 } 233 { 234 char end = 0; 235 if( (data[pos] == '(' && (end=')')) || 236 (data[pos] == '[' && (end=']')) ||
CID 1317354: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) During compilation of file '/home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike.c'
237 (data[pos] == '{' && (end='}')) ) 238 { 239 for (pos++; pos<len-1; pos++) 240 if (data[pos] == '#' && data[pos+1] == end) 241 { 242 pos++;
** CID 1317353: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) /home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike_tokenizer.h: 236 in ()
___________________________________________________________________________ *** CID 1317353: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) /home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike_tokenizer.h: 236 in () 230 goto failed_to_find_end; 231 break; 232 } 233 { 234 char end = 0; 235 if( (data[pos] == '(' && (end=')')) ||
CID 1317353: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) During compilation of file '/home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike.c'
236 (data[pos] == '[' && (end=']')) || 237 (data[pos] == '{' && (end='}')) ) 238 { 239 for (pos++; pos<len-1; pos++) 240 if (data[pos] == '#' && data[pos+1] == end) 241 {
** CID 1317352: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) /home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike_tokenizer.h: 235 in ()
_____________________________________________________________________________ *** CID 1317352: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) /home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike_tokenizer.h: 235 in () 229 if (pos >= len) 230 goto failed_to_find_end; 231 break; 232 } 233 { 234 char end = 0;
CID 1317352: Incorrect expression (PW.ASSIGN_WHERE_COMPARE_MEANT) During compilation of file '/home/covscan/pike/Pike-v8.0-snapshot/src/modules/Parser/pike.c'
235 if( (data[pos] == '(' && (end=')')) || 236 (data[pos] == '[' && (end=']')) || 237 (data[pos] == '{' && (end='}')) ) 238 { 239 for (pos++; pos<len-1; pos++) 240 if (data[pos] == '#' && data[pos+1] == end)
_____________________________________________________________________________
They are very, very intentional. I can't go to the Defects page since I changed email though.
Maybe the intent will be clearer with
if( (data[pos] == '(' && (end=')', TRUE)) ||
etc? No idea if it would make coverity happier, but it would probably make the occasional human reader so.
The end variable is defined in the line above, so it should be easy to see. But I just rewrote all of it instead of small tweaks.
The end variable is not the issue, it's the fact that the code is using the truth value of '(' for no good reason. Using (var=exp) in a conditional statement usually wants to find out if exp is nonzero as well as doing the assignment. Here _only_ the side effect of doing the assigment is desired, and the expression is meant to be always true. My suggested alternative clarifies that.
Looks like it. I thought the new defects like only listed uncategorized bugs, but that is not the case.
pike-devel@lists.lysator.liu.se