Julia,

if (foo) return 1; // or TRUE
return 0; // or FALSE

Actually, there are far more of these than I expected.  Or at least the

I'm seeing an order of magnitude more of these than the
return x; return x; pattern, with 1/3 having an else.

opposite case, with return 0 under the if.  But I'm not sure what the
improvement would be, unless it is known that foo is already 1, rather
than some other nonzero integer.  One could write return !!foo;, but I'm
not sure that that is an improvement.  And many have fairly complicated
test expressions.

Yes, many are surprisingly complicated.

Perhaps if Greg has more free time he will write an expression
simplifier :-)
Perhaps the first thing to handle at is "x ? 1 : 0" and its negation.

--
Derek M. Jones                         tel: +44 (0) 1252 520 667
Knowledge Software Ltd                 mailto:[email protected]
Source code analysis                   http://www.knosof.co.uk
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to