linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Sparse doesn't seem to care about checking context? data
@ 2014-09-09 20:51 Brett Nash
  0 siblings, 0 replies; only message in thread
From: Brett Nash @ 2014-09-09 20:51 UTC (permalink / raw)
  To: linux-sparse

[-- Attachment #1: Type: text/plain, Size: 395 bytes --]

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

[-- Attachment #2: sparse_context.c --]
[-- Type: text/x-csrc, Size: 359 bytes --]


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;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-09-09 21:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-09 20:51 Sparse doesn't seem to care about checking context? data Brett Nash

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).