On Tue, Nov 18, 2014 at 06:31:09PM +0300, Dan Carpenter wrote: > On Mon, Nov 17, 2014 at 06:13:51PM -0800, Jörn Engel wrote: > > > - smatch gave no warning. The README file in the git tree is for > > sparse, so I may have used it wrong. But with either default > > parameters of -Wuninitialized there is no warning. > > Sorry for that. I've pushed some changes so hopefully the documentation > to build and run is easier to find now. It's under Documentation/. Thank you! > > As a testcase, I can reduce the code down to nine lines: > > > > void callee(int *arg); > > int caller(void) > > { > > int arg; > > callee(&arg); > > if (!arg) > > return 1; > > return 0; > > } > > > > Is this something you could cook up a test for? I would like need two > > weeks to work myself through the source code before I can even get > > started. > > That test case will drive you nuts. You need to have cross function > analysis for there to be a manageable number of false positives. > > Smatch does cross function analysis, but playing with this I see that I > need to make some improvements here. There are still way way too many > false positives. I have some ideas here. > > Anyway, just for laughs, I've attached the check I'm working on. You'll > need to add it check_list.h and recompile. Wow! That was far faster than I had hoped for. I'll see if this is already useful somehow. Personally I would even be happy to annotate call-by-reference parameters with something like __set and __unset. If annotated with __set, callers can assume the parameter is initialized on function return and compilers can warn if the callee returns without initializing it. __unset is the opposite, warn in the caller if the parameter wasn't previously initialized. But I assume that Linus would hate this. He's never been very fond of annotating source code to make life easier on code checkers. Jörn -- Act only according to that maxim whereby you can, at the same time, will that it should become a universal law. -- Immanuel Kant -- To unsubscribe from this list: send the line "unsubscribe smatch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html