Context imbalance false positive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
        printk("I am a module, cheers!\n");
        unlock(1);
        return 0;
}

static void goodbye_exit(void)
{
        printk("Goodbye cruel world!\n");
}

module_init(hello_init);
module_exit(goodbye_exit);

----

Sparse complains with:
/home/mcgrof/devel/spin_lock_sparse/sparse_spinlock.c:14:3: warning:
context imbalance in 'lock': wrong count at exit
/home/mcgrof/devel/spin_lock_sparse/sparse_spinlock.c:14:3:    context
'lock': wanted 0, got 1
/home/mcgrof/devel/spin_lock_sparse/sparse_spinlock.c:20:3: warning:
context problem in 'unlock': '_spin_unlock_bh' expected different
context
/home/mcgrof/devel/spin_lock_sparse/sparse_spinlock.c:20:3:    context
'lock': wanted >= 1, got 0

You can test compile from files here:

http://ruslug.rutgers.edu/~mcgrof/spin_lock_sparse/

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

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux