From: Oleg Drokin <green@xxxxxxxxxxxxxx> When we have a merged state that consists of a single state only, e.g. because both true and false states are the same since the condition did not affect any of them - just clone one of the original states instead of creating a new one and assigning a current line number to it. This fixes an annoying problem where "xxx was used before see yyy" prints yyy line number that dates back to previous condition, not to actual usage. Additionally when dealing with "ghost" merges this fixes some false positives about lock imbalances for the case of if (condition) lock(x); some stuff; if (some other stuff) goto out; out: if (condition) unlock(x) Signed-off-by: Oleg Drokin <green@xxxxxxxxxxxxxx> --- I was long annoyed by this and so using my lustre tree as benchmark here is the difference in output before and after the patch for this file for wrong line numbers: http://git.whamcloud.com/fs/lustre-release.git/blob/943612ac470a1f916d44f551eee01c3d51fc9546:/lustre/lfsck/lfsck_layout.c -lustre/lfsck/lfsck_layout.c:2390 lfsck_layout_recreate_lovea() warn: variable dereferenced before check 'handle' (see line 2386) -lustre/lfsck/lfsck_layout.c:2415 lfsck_layout_recreate_lovea() warn: variable dereferenced before check 'handle' (see line 2411) +lustre/lfsck/lfsck_layout.c:2390 lfsck_layout_recreate_lovea() warn: variable dereferenced before check 'handle' (see line 2242) +lustre/lfsck/lfsck_layout.c:2415 lfsck_layout_recreate_lovea() warn: variable dereferenced before check 'handle' (see line 2242) Granted, this still remains a false positive, but thta would need a more involved fix in this particular check module. And here's the false positive that is now disappeared for this file: http://git.whamcloud.com/fs/lustre-release.git/blob/943612ac470a1f916d44f551eee01c3d51fc9546:/lustre/llite/llite_lib.c i lustre/llite/llite_lib.c:1709 ll_setattr_raw() warn: 'mutex:&inode->i_mutex' is sometimes locked here and sometimes unlocked. smatch_slist.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/smatch_slist.c b/smatch_slist.c index 55becc9..f6e60ac 100644 --- a/smatch_slist.c +++ b/smatch_slist.c @@ -374,7 +374,14 @@ struct sm_state *merge_sm_states(struct sm_state *one, struct sm_state *two) if (one == two) return one; s = merge_states(one->owner, one->name, one->sym, one->state, two->state); - result = alloc_state_no_name(one->owner, one->name, one->sym, s); + + if (s == one->state) + result = clone_sm(one); + else if (s == two->state) // What about custom merge? + result = clone_sm(two); + else + result = alloc_state_no_name(one->owner, one->name, one->sym, s); + result->merged = 1; result->left = one; result->right = two; -- 2.1.0 -- 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