We regularly check various projects to spread the word about static analysis methodology in general, and about our tool PVS-Studio in particular, so I couldn't miss a chance to check the Valgrind project. Here are interesting fragments that I managed to notice, perhaps, something should be fixed: https://www.viva64.com/en/b/0504/
Can you make a patch that fixes at least the more obvious problems (the ?: precedence ones in particular) ?
Yes, we can make patches, but I think it's not a very good idea. We don’t know the code much and can fix it incorrectly. And we have no opportunity to deal with every warning in detail. We regularly write articles about various projects, and we just don't have enough time to create such a large number of patches. Let me explain this with numbers. Now we have 11037 errors in the base ( https://www.viva64.com/en/examples/ ). If we start making patches for all of them, we’ll have to hire a whole new team for this. We aren’t that rich yet to do it. :) P.S. If you want, I could give a PVS-Studio license for Valgrind Team. I should warn right away, that there will be a lot of false positives. Most of all they will be caused by active usage of macros. If you are interested, contact me at karpov[@]viva64.com.
Thanks for reporting these suspicious pieces of code. I fixed 2 of the reported errors: - (info = NULL ? "" : info)); + (info == NULL ? "" : info)); and - taken_Jccs, taken_Jccs * 100.0 / total_Jccs ?: 1); + taken_Jccs, taken_Jccs * 100.0 / (total_Jccs ? total_Jccs : 1)); in revision 16379. Keeping the bug opened, as other reported problems still to be looked at.
Thanks Andrey. viva64 have some good tools that have helped in the past.