Skip to contentSkip to conversation

Sparse doesn't seem to care about checking context? data

DISCUSSION Brett Nash 1 participant 1 message Sep 9, 2014 Sparse checker

lore
Share & tools
lore

Brett Nash

author
#0 lore raw

Hello,

I was just testing sparse on a large (non-linux) code base using the __must_hold macro (eg __attribute__((context, 1, 1))).

However I don't seem to be able to trigger a warning from it.

I've attached a test case below, is there some magic I need to do get sparse to trigger on this case. I also note there are currently no tests in validation that check for this case.

Regards,
nash

static int must_hold(int x) __attribute__((context(1,1))) {
	int z;

	return x * 7;
}
static int release(int x) __attribute__((context(1, 0))) {
	__context__(-1);
	return 0;
}
static int acquiresilently(int x) {
	__context__(1);

	return 1;
}
int main(int argc, char **argv) {
	must_hold(8);
	__context__(1);
	must_hold(0);
	__context__(-1);
	return 0;
}