HI !
Noticed that the nuveau driver uses a fair number of if (var=val,boolean-condition){} which while legal C-code just makes it hard to read - and some seems buggy actually. The below spatch find about 50 cases - not sure though if this is actually complete ? thx! hofrat /// Check for unconditional code "hiding" in an if condition /// effectively that code is unconditionally executed before /// reaching the actual branch statement - which just makes it /// hard to read and thus is always wrong. /// Some of the cases found also look buggy /// In other cases some excess () are left in place in the /// generated patches - so some postprocessing may be needed. /// /// As of 5.0-rc8 all 50 cases look like they are found and fixed /// correctly - incorrectly only in the sense that the patched /// code is equivalent to the original code. but as this is in /// the nouveau driver only it might well be that this only /// fits that specific pattern and others might have wilder ways /// to achieve the same - so confidence Low for now /// // Confidence: Low // Comments: // Options: --no-includes --include-headers virtual patch virtual report @badif@ position p; statement S; expression E1,E2; @@ if@p (E1,E2) S @script:python depends on report@ p << badif.p; @@ msg = "unconditional code hiding in if condition" coccilib.report.print_report(p[0],msg) @fixbadif depends on badif && patch@ position p=badif.p; statement S; expression E1=badif.E1,E2=badif.E2; @@ + E1; if@p ( - E1, E2) S _______________________________________________ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci