linux: special logic in repetitive tests
Quoted 2 lines
There is a block of if tests against the same variable in
include/linux/mtd/pfow.hthat likely is defective
I wonder about this interpretation.
Quoted 3 lines
Likely the first test should be something like
if ((prog_status & 0x03) == 0x03)
Why would you prefer such a code variant?
Quoted 1 line
Is there a way for cocci to find this style of bitwise logic defect?
* Probably, yes.
* How often will this implementation detail really be a “defect”?
* Where do you stumble on difficulties to express a corresponding source code search pattern by the means of the semantic patch language?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 4 lines
Wonder harder.
If something is (& 3) it is also either (& 2 || & 1) so why have both below the first test?
I can interpret the source code example in the way that the number of set bits are checked.
I can eventually become concerned around the preferred coding style because of the usage of these constant values.
Would you like to check the use of bit fields?
Quoted 4 lines
Quoted 2 lines
* Where do you stumble on difficulties to express a corresponding source code search pattern by the means of the semantic patch language?
#defines, shifts, masks
You come along the usual development challenges for the safe handling of possible code variations.
With which approach would you like to start and perform further source code analysis?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 4 lines · Markus Elfring
Quoted 2 lines
There is a block of if tests against the same variable in
include/linux/mtd/pfow.hthat likely is defectiveI wonder about this interpretation.
Wonder harder.
If something is (& 3) it is also either (& 2 || & 1) so why have both below the first test?
Quoted 1 line
* How often will this implementation detail really be a “defect”?
Moderately likely.
Quoted 2 lines
* Where do you stumble on difficulties to express a corresponding source code search pattern by the means of the semantic patch language?
#defines, shifts, masks
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
Quoted 4 lines
Wonder harder.
If something is (& 3) it is also either (& 2 || & 1) so why have both below the first test?
Would you occasionally prefer to use enumeration values together with switch statements at such source code places?
Regards,
Markus
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci