On 10/5/06, Sam Ravnborg <sam@xxxxxxxxxxxx> wrote:
On Thu, Oct 05, 2006 at 01:41:03AM -0700, Dan Carpenter wrote: > Work on smatch is going ahead. I have one real life check is working > and I've added a patched up the core code quite a bit. For the mindless - can you please repeat what smatch does? Sam
It's a static code checker. Take a look at check_null_deref.c. You've got a function called match_assign() that gets called for every assignment: name = get_variable_from_expr(expr->left, &sym); name = alloc_string(name); if (is_null(expr->right)) set_state(name, my_id, sym, ISNULL); else set_state(name, my_id, sym, NONNULL); Say it encounter the code: a = foo(), then it's going to set the state of 'a' to NONNULL; Then say it encounters a call to tty_ldisc_deref(), it's going to check the state of 'a' and if it's ISNULL or UNDEFINED it's going to print a message out. More often you have something like: a = NULL; if (b) { a = foo(); } a->x; <---Error. 'a' is Undefined. The idea is that it's easy to write checks once all the state tracking code is in place. Use it like this: make C=1 CHECK=/path/to/smatch > warns.out 2>&1 regards, dan carpenter - To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html