Hi, the following patch activates context checking when context input and output values are the same and different of zero in __attribute__((context())), by making the parser generate a OP_CONTEXT pseudo instruction. Use case: specify that a function needs to be called in locked context. Below is a sample case. --- #define __needlock __attribute__((context(lock,1,1))) #define __acquire(x) __context__(1) #define __release(x) __context__(-1) static int __needlock test1(void) { return 0; } static int __needlock test2(void) { return test1(); /* OK */ } static int test3(void) { return test1(); /* should generate a warning */ } int main(void) { test1(); /* should generate a warning */ test2(); /* should generate a warning */ test3(); /* OK */ __acquire(); test1(); /* OK */ __release(); return -1; } --- I have used it on a relative big bunch of code and I believe it works well. Thanks, signed-off-by: Sylvain Nahas <sylvain.nahas@googlemailcom> --- --- a/linearize.c +++ b/linearize.c @@ -1244,6 +1244,12 @@ static pseudo_t linearize_call_expression(struct entrypoint *ep, struct expressi out = 0; } context_diff = out - in; + + if( !context_diff && (in>0) ){ + check = 1; + context_diff = in; + } + if (check || context_diff) { insn = alloc_instruction(OP_CONTEXT, 0); insn->increment = context_diff; - 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