From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: David Lechner <dlechner@baylibre.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: <amadeuszx.slawinski@linux.intel.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
<nex.sw.ncis.osdt.itp.upstreaming@intel.com>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
Markus Elfring <Markus.Elfring@web.de>,
Dan Carpenter <dan.carpenter@linaro.org>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Subject: Re: [PATCH v2] cleanup: adjust scoped_guard() to avoid potential warning
Date: Fri, 11 Oct 2024 09:25:17 +0200 [thread overview]
Message-ID: <b3dde971-eed4-4e7f-bb3b-6a761de65009@intel.com> (raw)
In-Reply-To: <0f4786e9-d738-435d-afb9-8c0c4a028ddb@baylibre.com>
On 10/10/24 22:13, David Lechner wrote:
> On 10/9/24 6:44 AM, Przemek Kitszel wrote:
>> Change scoped_guard() to make reasoning about it easier for static
>> analysis tools (smatch, compiler diagnostics), especially to enable them
>> to tell if the given scoped_guard() is conditional (interruptible-locks,
>> try-locks) or not (like simple mutex_lock()).
>>
>> Add compile-time error if scoped_cond_guard() is used for non-conditional
>> lock class.
>>
>> Beyond easier tooling and a little shrink reported by bloat-o-meter:
>> add/remove: 3/2 grow/shrink: 45/55 up/down: 1573/-2069 (-496)
>> this patch enables developer to write code like:
>>
>> int foo(struct my_drv *adapter)
>> {
>> scoped_guard(spinlock, &adapter->some_spinlock)
>> return adapter->spinlock_protected_var;
>> }
>>>
>> Current scoped_guard() implementation does not support that,
>> due to compiler complaining:
>> error: control reaches end of non-void function [-Werror=return-type]
>
> I was hoping that this would allow us to do the same with
> scoped_cond_guard() so that we could remove a bunch of
> unreachable(); that we had to add in the IIO subsystem. But
> with this patch we still get compile errors if we remove them.
>
> Is it possible to apply the same if/goto magic to scoped_cond_guard()
> to make it better too?
sure, will do
I will also combine both macros __helper at the same time to reduce
duplication
prev parent reply other threads:[~2024-10-11 7:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-09 11:44 [PATCH v2] cleanup: adjust scoped_guard() to avoid potential warning Przemek Kitszel
2024-10-09 13:21 ` Andy Shevchenko
2024-10-10 20:13 ` David Lechner
2024-10-11 7:25 ` Przemek Kitszel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b3dde971-eed4-4e7f-bb3b-6a761de65009@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=Markus.Elfring@web.de \
--cc=amadeuszx.slawinski@linux.intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=dan.carpenter@linaro.org \
--cc=dlechner@baylibre.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox