Re: [PATCH v2] coccinelle: locks: Add must_hold.cocci
From: Bart Van Assche
Date: Fri Nov 20 2026 - 13:21:49 EST
On 11/20/26 1:26 AM, Marco Elver wrote:
+ATTRS = re.compile(r'__(must_hold|must_hold_shared|releases|releases_shared|'
+ r'context_unsafe|no_context_analysis)\b')
Should __cond_acquires and __cond_releases be included in this
expression?
+def missing_must_hold(f, a, E, pf, p):
+ e = re.sub(r'\s+', '', E)
re.sub(r'\s+', '', E) turns (struct foo *)p into (structfoo*)p. Can this cause a silent false negative and garbled report text? Collapsing whitespace instead of removing it would keep tokens separate.
Additionally, missing_must_hold() re-reads the file, runs splitlines() on all of it and regex-scans it for every match. Has caching per file been considered? Would this help on a full-tree make coccicheck?
Thanks,
Bart.