Luis R. Rodriguez | 18 Jul 01:51

Context imbalance false positive

I'm not sure how to resolve a situation like this:

#include <linux/module.h>
#include <linux/spinlock.h>

MODULE_AUTHOR("Luis R. Rodriguez");
MODULE_LICENSE("GPL");

static spinlock_t some_lock;

static void lock(int bh_flag)
{
        if (bh_flag)
                spin_lock_bh(&some_lock);
        else
                spin_lock(&some_lock);
}

static void unlock(int bh_flag)
{
        if (bh_flag)
                spin_unlock_bh(&some_lock);
        else
                spin_unlock(&some_lock);
}

static int hello_init(void)
{
        spin_lock_init(&some_lock);
        lock(1);
(Continue reading)

Johannes Berg | 18 Jul 10:25
Favicon

Re: Context imbalance false positive

On Thu, 2008-07-17 at 16:52 -0700, Luis R. Rodriguez wrote:
> I'm not sure how to resolve a situation like this:

> static void lock(int bh_flag)
> {
>         if (bh_flag)
>                 spin_lock_bh(&some_lock);
>         else
>                 spin_lock(&some_lock);

The only generally accepted way is to not program locking dependent on
flags.

You can sneak in sparse annotations to do it anyway, but I won't tell
you how :)

johannes
Luis R. Rodriguez | 18 Jul 16:25

Re: Context imbalance false positive

On Fri, Jul 18, 2008 at 1:25 AM, Johannes Berg
<johannes <at> sipsolutions.net> wrote:
> On Thu, 2008-07-17 at 16:52 -0700, Luis R. Rodriguez wrote:
>> I'm not sure how to resolve a situation like this:
>
>> static void lock(int bh_flag)
>> {
>>         if (bh_flag)
>>                 spin_lock_bh(&some_lock);
>>         else
>>                 spin_lock(&some_lock);
>
> The only generally accepted way is to not program locking dependent on
> flags.

Agreed, and that's what I'm trying to do actually. I think the above
is pure absolute garbage.

> You can sneak in sparse annotations to do it anyway, but I won't tell
> you how :)

If you mean by __acquires() and __releases() then that didn't help.

  Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

(Continue reading)


Gmane