Commit a577850e authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Address several issues reported by cppcheck all over the place.

* src/bin/common_finput.cc, src/tgbaalgos/lbtt.cc: Use !empty() instead
of size() > 0.
* src/bin/ltl2tgta.cc, src/kripke/kripkeexplicit.cc,
src/tgbatest/complementation.cc: Avoid useless assignments.
* src/bin/ltlcross.cc: Correct mistaken assignment inside assert().
* src/evtgba/symbol.hh, src/tgba/tgbabddcoredata.cc,
src/tgba/tgbabddcoredata.hh,
src/tgba/tgbasafracomplement.cc (operator=): Do not return a const
reference.
* src/evtgbatest/ltl2evtgba.cc, src/evtgbatest/product.cc,
src/evtgbatest/product.cc: Check indices before using them, not after.
* src/kripke/kripkeexplicit.cc, src/kripke/kripkeexplicit.hh,
src/tgbatest/randtgba.cc: Pass constant strings by reference.
* src/kripke/kripkeprint.cc, src/tgbaalgos/simulation.cc:
Remove a useless operation.
* src/ltlvisit/simplify.cc: Remove a duplicate condition.
* src/misc/formater.hh: Remove unused attribute.
* src/misc/modgray.cc: Initialize done_ in the constructor.
* src/saba/explicitstateconjunction.cc,
src/saba/explicitstateconjunction.hh (operator=): Fix prototype.
* src/saba/sabacomplementtgba.cc: Remove unused default constructor.
* src/ta/taexplicit.cc, src/ta/taproduct.cc, src/ta/tgtaproduct.cc,
src/ta/tgtaproduct.hh, src/taalgos/emptinessta.cc,
src/taalgos/minimize.cc, src/taalgos/reachiter.cc,
src/taalgos/tgba2ta.cc, src/tgbaalgos/cutscc.cc: Use C++ casts, and
++it instead of it++.
* src/taalgos/dotty.cc, src/tgbatest/ltl2tgba.cc: Refine the scope of
variables.
* src/tgba/tgbakvcomplement.hh (bdd_order): Always initialize bdd_.
* src/tgba/tgbasgba.cc, src/tgba/wdbacomp.cc: Use the initialization
line to initialize all members.
parent a3b49f11
......@@ -94,7 +94,7 @@ job_processor::process_string(const std::string& input,
spot::ltl::parse_error_list pel;
const spot::ltl::formula* f = parse_formula(input, pel);
if (!f || pel.size() > 0)
if (!f || !pel.empty())
{
if (filename)
error_at_line(0, 0, filename, linenum, "parse error:");
......
......@@ -199,12 +199,11 @@ namespace
if (ta_type != TGTA)
{
spot::ta* testing_automaton = 0;
testing_automaton = tgba_to_ta(aut, ap_set,
type == spot::postprocessor::BA,
opt_with_artificial_initial_state,
opt_single_pass_emptiness_check,
opt_with_artificial_livelock);
spot::ta* testing_automaton =
tgba_to_ta(aut, ap_set, type == spot::postprocessor::BA,
opt_with_artificial_initial_state,
opt_single_pass_emptiness_check,
opt_with_artificial_livelock);
if (level != spot::postprocessor::Low)
{
spot::ta* testing_automaton_nm = testing_automaton;
......
......@@ -744,7 +744,7 @@ namespace
states_in_acc(neg, sspace, s);
bool res = s.size() == states;
state_set::iterator it;
for (it = s.begin(); it != s.end(); it++)
for (it = s.begin(); it != s.end(); ++it)
(*it)->destroy();
return res;
}
......@@ -1001,7 +1001,7 @@ print_stats_csv(const char* filename)
unsigned ntrans = translators.size();
unsigned rounds = vstats.size();
assert(rounds = formulas.size());
assert(rounds == formulas.size());
*out << "\"formula\", \"tool\", ";
statistics::fields(*out);
......@@ -1039,7 +1039,7 @@ print_stats_json(const char* filename)
unsigned ntrans = translators.size();
unsigned rounds = vstats.size();
assert(rounds = formulas.size());
assert(rounds == formulas.size());
*out << "{\n \"tools\": [\n \"";
spot::escape_str(*out, translators[0]);
......
......@@ -83,7 +83,7 @@ namespace spot
return s_;
}
const rsymbol&
rsymbol&
operator=(const rsymbol& rs)
{
if (this != &rs)
......
......@@ -58,7 +58,7 @@ main(int argc, char** argv)
spot::ltl::environment& env(spot::ltl::default_environment::instance());
spot::ltl::atomic_prop_set* unobservables = new spot::ltl::atomic_prop_set;
while (argv[formula_index][0] == '-' && formula_index < argc)
while (formula_index < argc && argv[formula_index][0] == '-')
{
if (!strcmp(argv[formula_index], "-d"))
{
......
// Copyright (C) 2008 Laboratoire de Recherche et Dveloppement
// -*- coding: utf-8 -*-
// Copyright (C) 2008, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris
// 6 (LIP6), dpartement Systmes Rpartis Coopratifs (SRC),
// Universit Pierre et Marie Curie.
// 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
// Université Pierre et Marie Curie.
//
// This file is part of Spot, a model checking library.
//
......@@ -47,7 +48,7 @@ main(int argc, char** argv)
bool dotty = false;
int filename_index = 1;
while (argv[filename_index][0] == '-' && filename_index < argc)
while (filename_index < argc && argv[filename_index][0] == '-')
{
if (!strcmp(argv[filename_index], "-d"))
debug = true;
......
// Copyright (C) 2011 Laboratoire de Recherche et Developpement
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
//
// This file is part of Spot, a model checking library.
......@@ -153,7 +153,7 @@ namespace spot
{
dict_->unregister_all_my_variables(this);
std::map<const std::string, state_kripke*>::iterator it;
for (it = ns_nodes_.begin(); it != ns_nodes_.end(); it++)
for (it = ns_nodes_.begin(); it != ns_nodes_.end(); ++it)
{
state_kripke* del_me = it->second;
delete del_me;
......@@ -195,7 +195,7 @@ namespace spot
}
bdd
kripke_explicit::state_condition(const std::string name) const
kripke_explicit::state_condition(const std::string& name) const
{
std::map<const std::string, state_kripke*>::const_iterator it;
it = ns_nodes_.find(name);
......@@ -247,13 +247,12 @@ namespace spot
void kripke_explicit::add_transition(std::string source,
std::string dest)
{
state_kripke* neo = 0;
std::map<std::string, state_kripke*>::iterator destination
= ns_nodes_.find(dest);
if (ns_nodes_.find(dest) == ns_nodes_.end())
{
neo = new state_kripke;
state_kripke* neo = new state_kripke;
add_state(dest, neo);
add_transition(source, neo);
}
......
......@@ -131,7 +131,7 @@ namespace spot
/// \brief Get the condition on the state
bdd state_condition(const state* s) const;
/// \brief Get the condition on the state
bdd state_condition(const std::string) const;
bdd state_condition(const std::string&) const;
/// \brief Return the name of the state.
std::string format_state(const state*) const;
......
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012 Laboratoire de Recherche et Developpement
// de l'Epita (LRDE)
//
......@@ -88,7 +89,6 @@ namespace spot
notfirst = true;
const bdd_dict* d = aut_->get_dict();
std::string cur = aut_->format_state(s);
os_ << "S" << in_s << ", \"";
const kripke* automata = down_cast<const kripke*>(aut_);
assert(automata);
......
......@@ -2388,7 +2388,6 @@ namespace spot
&& (op != multop::AndNLM)
&& (op != multop::OrRat)
&& (op != multop::Concat)
&& (op != multop::Concat)
&& (op != multop::Fusion))
{
bool is_and = op == multop::And;
......@@ -2442,7 +2441,7 @@ namespace spot
else if (c_->implication_neg(*f1, *f2, is_and))
{
for (multop::vec::iterator j = res->begin();
j != res->end(); j++)
j != res->end(); ++j)
if (*j)
(*j)->destroy();
delete res;
......
......@@ -180,7 +180,6 @@ namespace spot
std::vector<const printable*> call_;
protected:
std::ostream* output_;
const char* pos_;
};
}
......
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// dpartement Systmes Rpartis Coopratifs (SRC), Universit Pierre
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
// et Marie Curie.
//
// This file is part of Spot, a model checking library.
......@@ -24,7 +27,7 @@ namespace spot
loopless_modular_mixed_radix_gray_code::
loopless_modular_mixed_radix_gray_code(int n)
: n_(n), a_(0), f_(0), m_(0), s_(0), non_one_radixes_(0)
: n_(n), done_(false), a_(0), f_(0), m_(0), s_(0), non_one_radixes_(0)
{
}
......
// Copyright (C) 2009 Laboratoire de Recherche et Développement
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -34,7 +35,7 @@ namespace spot
{
}
explicit_state_conjunction*
explicit_state_conjunction&
explicit_state_conjunction::operator=(const explicit_state_conjunction& o)
{
if (this != &o)
......@@ -42,7 +43,7 @@ namespace spot
this->~explicit_state_conjunction();
new (this) explicit_state_conjunction(&o);
}
return this;
return *this;
}
explicit_state_conjunction::~explicit_state_conjunction()
......
// Copyright (C) 2009 Laboratoire de Recherche et Développement
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2012 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
......@@ -37,7 +38,7 @@ namespace spot
explicit_state_conjunction(const explicit_state_conjunction* other);
virtual ~explicit_state_conjunction();
explicit_state_conjunction* operator=(const explicit_state_conjunction& o);
explicit_state_conjunction& operator=(const explicit_state_conjunction& o);
/// \name Iteration
//@{
......
// Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// -*- coding: utf-8 -*-
// Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
......@@ -68,10 +69,6 @@ namespace spot
bdd condition_;
};
saba_state_complement_tgba::saba_state_complement_tgba()
{
}
saba_state_complement_tgba::saba_state_complement_tgba(shared_state state,
rank_t rank,
bdd condition)
......
......@@ -151,7 +151,7 @@ namespace spot
bool transition_found = false;
for (it_trans = trans_by_condition->begin(); (it_trans
!= trans_by_condition->end() && !transition_found); it_trans++)
!= trans_by_condition->end() && !transition_found); ++it_trans)
{
transition_found = ((*it_trans)->dest == t->dest);
if (transition_found)
......@@ -240,7 +240,7 @@ namespace spot
int
state_ta_explicit::compare(const spot::state* other) const
{
const state_ta_explicit* o = down_cast<const state_ta_explicit*> (other);
const state_ta_explicit* o = down_cast<const state_ta_explicit*>(other);
assert(o);
int compare_value = tgba_state_->compare(o->tgba_state_);
......@@ -286,7 +286,8 @@ namespace spot
state_ta_explicit* dest = (*it_trans)->dest;
bool is_stuttering_transition = (get_tgba_condition()
== (dest)->get_tgba_condition());
bool dest_is_livelock_accepting = dest->is_livelock_accepting_state();
bool dest_is_livelock_accepting =
dest->is_livelock_accepting_state();
//Before deleting stuttering transitions, propaged back livelock
//and initial state's properties
......@@ -329,7 +330,7 @@ namespace spot
// We don't destroy the transitions in the state's destructor because
// they are not cloned.
if (trans != 0)
for (it_trans = trans->begin(); it_trans != trans->end(); it_trans++)
for (it_trans = trans->begin(); it_trans != trans->end(); ++it_trans)
{
delete *it_trans;
}
......@@ -369,9 +370,9 @@ namespace spot
ta_explicit::~ta_explicit()
{
ta::states_set_t::iterator it;
for (it = states_set_.begin(); it != states_set_.end(); it++)
for (it = states_set_.begin(); it != states_set_.end(); ++it)
{
state_ta_explicit* s = down_cast<state_ta_explicit*> (*it);
state_ta_explicit* s = down_cast<state_ta_explicit*>(*it);
s->free_transitions();
s->get_tgba_state()->destroy();
......@@ -388,14 +389,13 @@ namespace spot
std::pair<ta::states_set_t::iterator, bool> add_state_to_ta =
states_set_.insert(s);
return static_cast<state_ta_explicit*> (*add_state_to_ta.first);
return static_cast<state_ta_explicit*>(*add_state_to_ta.first);
}
void
ta_explicit::add_to_initial_states_set(state* state, bdd condition)
{
state_ta_explicit * s = down_cast<state_ta_explicit*> (state);
assert(s);
state_ta_explicit* s = down_cast<state_ta_explicit*>(state);
s->set_initial_state(true);
if (condition == bddfalse)
condition = get_state_condition(s);
......@@ -403,15 +403,17 @@ namespace spot
initial_states_set_.insert(s);
if (get_artificial_initial_state() != 0)
if (add_state.second)
create_transition((state_ta_explicit*) get_artificial_initial_state(),
condition, bddfalse, s);
{
state_ta_explicit* i =
down_cast<state_ta_explicit*>(get_artificial_initial_state());
create_transition(i, condition, bddfalse, s);
}
}
void
ta_explicit::delete_stuttering_and_hole_successors(spot::state* s)
{
state_ta_explicit * state = down_cast<state_ta_explicit*> (s);
state_ta_explicit * state = down_cast<state_ta_explicit*>(s);
assert(state);
state->delete_stuttering_and_hole_successors();
if (state->is_initial_state())
......@@ -421,7 +423,8 @@ namespace spot
void
ta_explicit::create_transition(state_ta_explicit* source, bdd condition,
bdd acceptance_conditions, state_ta_explicit* dest, bool add_at_beginning)
bdd acceptance_conditions,
state_ta_explicit* dest, bool add_at_beginning)
{
state_ta_explicit::transition* t = new state_ta_explicit::transition;
t->dest = dest;
......@@ -442,7 +445,7 @@ namespace spot
ta_explicit::get_state_condition(const spot::state* initial_state) const
{
const state_ta_explicit* sta =
down_cast<const state_ta_explicit*> (initial_state);
down_cast<const state_ta_explicit*>(initial_state);
assert(sta);
return sta->get_tgba_condition();
}
......@@ -450,7 +453,7 @@ namespace spot
bool
ta_explicit::is_accepting_state(const spot::state* s) const
{
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
const state_ta_explicit* sta = down_cast<const state_ta_explicit*>(s);
assert(sta);
return sta->is_accepting_state();
}
......@@ -458,7 +461,7 @@ namespace spot
bool
ta_explicit::is_initial_state(const spot::state* s) const
{
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
const state_ta_explicit* sta = down_cast<const state_ta_explicit*>(s);
assert(sta);
return sta->is_initial_state();
}
......@@ -466,7 +469,7 @@ namespace spot
bool
ta_explicit::is_livelock_accepting_state(const spot::state* s) const
{
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
const state_ta_explicit* sta = down_cast<const state_ta_explicit*>(s);
assert(sta);
return sta->is_livelock_accepting_state();
}
......@@ -474,7 +477,7 @@ namespace spot
ta_succ_iterator*
ta_explicit::succ_iter(const spot::state* state) const
{
const state_ta_explicit* s = down_cast<const state_ta_explicit*> (state);
const state_ta_explicit* s = down_cast<const state_ta_explicit*>(state);
assert(s);
return new ta_explicit_succ_iterator(s);
}
......@@ -482,7 +485,7 @@ namespace spot
ta_succ_iterator*
ta_explicit::succ_iter(const spot::state* state, bdd condition) const
{
const state_ta_explicit* s = down_cast<const state_ta_explicit*> (state);
const state_ta_explicit* s = down_cast<const state_ta_explicit*>(state);
assert(s);
return new ta_explicit_succ_iterator(s, condition);
}
......@@ -502,7 +505,7 @@ namespace spot
std::string
ta_explicit::format_state(const spot::state* s) const
{
const state_ta_explicit* sta = down_cast<const state_ta_explicit*> (s);
const state_ta_explicit* sta = down_cast<const state_ta_explicit*>(s);
assert(sta);
if (sta->get_tgba_condition() == bddtrue)
......@@ -517,11 +520,11 @@ namespace spot
ta_explicit::delete_stuttering_transitions()
{
ta::states_set_t::iterator it;
for (it = states_set_.begin(); it != states_set_.end(); it++)
for (it = states_set_.begin(); it != states_set_.end(); ++it)
{
const state_ta_explicit* source =
static_cast<const state_ta_explicit*> (*it);
static_cast<const state_ta_explicit*>(*it);
state_ta_explicit::transitions* trans = source->get_transitions();
state_ta_explicit::transitions::iterator it_trans;
......
......@@ -288,7 +288,7 @@ namespace spot
ta_init_states_set = ta_->get_initial_states_set();
}
for (it = ta_init_states_set.begin(); it != ta_init_states_set.end(); it++)
for (it = ta_init_states_set.begin(); it != ta_init_states_set.end(); ++it)
{
if ((artificial_initial_state != 0) || (kripke_init_state_condition
......
// -*- coding: utf-8 -*-
// Copyright (C) 2012 Laboratoire de Recherche et Developpement
// de l Epita (LRDE).
//
......@@ -64,8 +65,9 @@ namespace spot
fixed_size_pool* p = const_cast<fixed_size_pool*> (&pool_);
return new tgta_succ_iterator_product(s, (const kripke*) left_,
(const tgta *) right_, p);
return new tgta_succ_iterator_product(s,
down_cast<const kripke*>(left_),
down_cast<const tgta*>(right_), p);
}
////////////////////////////////////////////////////////////
......
......@@ -36,7 +36,6 @@ namespace spot
class tgta_product : public tgba_product
{
public:
tgta_product(const kripke* left, const tgta* right);
virtual state*
......@@ -45,8 +44,6 @@ namespace spot
virtual tgba_succ_iterator*
succ_iter(const state* local_state, const state* global_state = 0,
const tgba* global_automaton = 0) const;
};
/// \brief Iterate over the successors of a product computed on the fly.
......@@ -100,9 +97,7 @@ namespace spot
bdd current_condition_;
bdd current_acceptance_conditions_;
bdd kripke_source_condition;
state * kripke_current_dest_state;
state* kripke_current_dest_state;
};
}
......
// -*- coding: utf-8 -*-
// Copyright (C) 2010, 2012 Laboratoire de Recherche et Developpement
// de l Epita (LRDE).
//
......@@ -40,8 +41,6 @@ namespace spot
{
os_ << "digraph G {" << std::endl;
int n = 0;
artificial_initial_state_ = t_automata_->get_artificial_initial_state();
ta::states_set_t init_states_set;
......@@ -55,10 +54,10 @@ namespace spot
}
else
{
int n = 0;
init_states_set = t_automata_->get_initial_states_set();
for (it = init_states_set.begin();
it != init_states_set.end(); it++)
it != init_states_set.end(); ++it)
{
bdd init_condition = t_automata_->get_state_condition(*it);
std::string label = bdd_format_formula(t_automata_->get_dict(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment