projects
/
model-checker.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
538175b
)
model: get_last_conflict - replace if/else-if block with switch
author
Brian Norris
<banorris@uci.edu>
Thu, 20 Sep 2012 17:08:03 +0000
(10:08 -0700)
committer
Brian Norris
<banorris@uci.edu>
Thu, 20 Sep 2012 17:08:03 +0000
(10:08 -0700)
model.cc
patch
|
blob
|
history
diff --git
a/model.cc
b/model.cc
index 02518eef53078cc2618a56e0f75d4c00a2a27ccc..fba2fe5c3ede9f821e1d54743d3f8ea894ebd017 100644
(file)
--- a/
model.cc
+++ b/
model.cc
@@
-200,9
+200,10
@@
bool ModelChecker::next_execution()
ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
{
ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
{
- action_type type = act->get_type();
-
- if (type==ATOMIC_READ||type==ATOMIC_WRITE||type==ATOMIC_RMW) {
+ switch (act->get_type()) {
+ case ATOMIC_READ:
+ case ATOMIC_WRITE:
+ case ATOMIC_RMW: {
/* linear search: from most recent to oldest */
action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
/* linear search: from most recent to oldest */
action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
@@
-211,7
+212,10
@@
ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
if (act->is_synchronizing(prev))
return prev;
}
if (act->is_synchronizing(prev))
return prev;
}
- } else if (type==ATOMIC_LOCK||type==ATOMIC_TRYLOCK) {
+ break;
+ }
+ case ATOMIC_LOCK:
+ case ATOMIC_TRYLOCK: {
/* linear search: from most recent to oldest */
action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
/* linear search: from most recent to oldest */
action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
@@
-220,7
+224,9
@@
ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
if (act->is_conflicting_lock(prev))
return prev;
}
if (act->is_conflicting_lock(prev))
return prev;
}
- } else if (type==ATOMIC_UNLOCK) {
+ break;
+ }
+ case ATOMIC_UNLOCK: {
/* linear search: from most recent to oldest */
action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
/* linear search: from most recent to oldest */
action_list_t *list = obj_map->get_safe_ptr(act->get_location());
action_list_t::reverse_iterator rit;
@@
-229,6
+235,10
@@
ModelAction * ModelChecker::get_last_conflict(ModelAction *act)
if (!act->same_thread(prev)&&prev->is_failed_trylock())
return prev;
}
if (!act->same_thread(prev)&&prev->is_failed_trylock())
return prev;
}
+ break;
+ }
+ default:
+ break;
}
return NULL;
}
}
return NULL;
}