scst: Exclude certain locking code from static analysis

Loops with locking statements and also lock and unlock
statements guarded by an if-statement trigger false positive
warnings when analyzing the SCST code with smatch and/or sparse.
Hence exclude such code from static analysis.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5616 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2014-06-20 04:05:11 +00:00
parent 6b32f4ae81
commit 23116c1598
2 changed files with 12 additions and 0 deletions

View File

@@ -2539,6 +2539,7 @@ static void scst_queue_report_luns_changed_UA(struct scst_session *sess,
local_bh_disable();
#if !defined(__CHECKER__)
for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) {
head = &sess->sess_tgt_dev_list[i];
@@ -2548,6 +2549,7 @@ static void scst_queue_report_luns_changed_UA(struct scst_session *sess,
spin_lock(&tgt_dev->tgt_dev_lock);
}
}
#endif
for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) {
head = &sess->sess_tgt_dev_list[i];
@@ -2568,6 +2570,7 @@ static void scst_queue_report_luns_changed_UA(struct scst_session *sess,
}
}
#if !defined(__CHECKER__)
for (i = SESS_TGT_DEV_LIST_HASH_SIZE-1; i >= 0; i--) {
head = &sess->sess_tgt_dev_list[i];
@@ -2576,6 +2579,7 @@ static void scst_queue_report_luns_changed_UA(struct scst_session *sess,
spin_unlock(&tgt_dev->tgt_dev_lock);
}
}
#endif
local_bh_enable();
@@ -8304,6 +8308,7 @@ again:
if (UA_entry->global_UA && first) {
TRACE_MGMT_DBG("Global UA %p detected", UA_entry);
#if !defined(__CHECKER__)
spin_unlock_bh(&cmd->tgt_dev->tgt_dev_lock);
/*
@@ -8323,6 +8328,7 @@ again:
spin_lock(&tgt_dev->tgt_dev_lock);
}
}
#endif
first = false;
global_unlock = true;
@@ -8385,6 +8391,7 @@ again:
out_unlock:
if (global_unlock) {
#if !defined(__CHECKER__)
for (i = SESS_TGT_DEV_LIST_HASH_SIZE-1; i >= 0; i--) {
struct list_head *head = &sess->sess_tgt_dev_list[i];
struct scst_tgt_dev *tgt_dev;
@@ -8396,6 +8403,7 @@ out_unlock:
local_bh_enable();
spin_lock_bh(&cmd->tgt_dev->tgt_dev_lock);
#endif
}
spin_unlock_bh(&cmd->tgt_dev->tgt_dev_lock);

View File

@@ -456,8 +456,10 @@ static struct scst_dev_registrant *scst_pr_add_registrant(
* We can't use scst_mutex here, because of the circular
* locking dependency with dev_pr_mutex.
*/
#if !defined(__CHECKER__)
if (!dev_lock_locked)
spin_lock_bh(&dev->dev_lock);
#endif
list_for_each_entry(t, &dev->dev_tgt_dev_list, dev_tgt_dev_list_entry) {
if (tid_equal(t->sess->transport_id, transport_id) &&
(t->sess->tgt->rel_tgt_id == rel_tgt_id) &&
@@ -472,8 +474,10 @@ static struct scst_dev_registrant *scst_pr_add_registrant(
break;
}
}
#if !defined(__CHECKER__)
if (!dev_lock_locked)
spin_unlock_bh(&dev->dev_lock);
#endif
list_add_tail(&reg->dev_registrants_list_entry,
&dev->dev_registrants_list);