[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CANiDSCs8i5Eid-FhDkgxTghFu8Sk831SojZwAohJ-CbKRch5KQ@mail.gmail.com>
Date: Mon, 6 May 2024 20:38:15 +0200
From: Ricardo Ribalda <ribalda@...omium.org>
To: Peter Zijlstra <peterz@...radead.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Conditional guards
Hi Peter
Probably a stupid question.... but I'd rather ask the expert directly :)
I am trying to fix some of the cocci warnings with guard() and there
is a use case that I do not know how to do. I have something like:
void use_hardware(priv) {
if (priv->model == 42)
mutex_lock(&priv->lock):
// DO things here
if (priv->model == 42)
mutex_unlock(&priv->lock):
}
if I replace:
if (priv->model == 42)
mutex_lock(&priv->lock):
with
if (priv->model == 42)
guard(mutex)(&priv->lock)
gcc screams at me:
drivers/media/dvb-core/dvb_frontend.c: In function ‘dvb_frontend_open’:
/include/linux/cleanup.h:119:9: error: expected expression before
‘class_mutex_t’
119 | class_##_name##_t var
__cleanup(class_##_name##_destructor) = \
| ^~~~~~
/include/linux/cleanup.h:164:9: note: in expansion of macro ‘CLASS’
164 | CLASS(_name, __UNIQUE_ID(guard))
| ^~~~~
drivers/media/dvb-core/dvb_frontend.c:2776:17: note: in expansion of
macro ‘guard’
2776 | guard(mutex)(&apadter->mfe_lock);
Is there a way to support something like this?
Regards!
--
Ricardo Ribalda
Powered by blists - more mailing lists