[PPL-devel] [GIT] ppl/ppl(master): Avoid implicit conversions to bool ( prefer explicit tests against zero).
Enea Zaffanella
zaffanella at cs.unipr.it
Thu Mar 1 22:36:59 CET 2012
Module: ppl/ppl
Branch: master
Commit: 7cab131006b0385c9855b298de5e0b85d8f05101
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=7cab131006b0385c9855b298de5e0b85d8f05101
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Thu Mar 1 22:24:52 2012 +0100
Avoid implicit conversions to bool (prefer explicit tests against zero).
Detected by ECLAIR service utypflag.
---
src/Polyhedron_public.cc | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/Polyhedron_public.cc b/src/Polyhedron_public.cc
index 0f8e3cf..31f2c7d 100644
--- a/src/Polyhedron_public.cc
+++ b/src/Polyhedron_public.cc
@@ -1191,28 +1191,32 @@ PPL::Polyhedron::OK(bool check_not_empty) const {
for (dimension_type i = sat_c.num_rows(); i-- > 0; ) {
const Generator tmp_gen = gen_sys[i];
const Bit_Row tmp_sat = sat_c[i];
- for (dimension_type j = sat_c.num_columns(); j-- > 0; )
- if (Scalar_Products::sign(con_sys[j], tmp_gen) != tmp_sat[j]) {
+ for (dimension_type j = sat_c.num_columns(); j-- > 0; ) {
+ const bool sat_j = (Scalar_Products::sign(con_sys[j], tmp_gen) == 0);
+ if (sat_j == tmp_sat[j]) {
#ifndef NDEBUG
cerr << "sat_c is declared up-to-date, but it is not!"
<< endl;
#endif
goto bomb;
}
+ }
}
if (sat_g_is_up_to_date())
for (dimension_type i = sat_g.num_rows(); i-- > 0; ) {
const Constraint tmp_con = con_sys[i];
const Bit_Row tmp_sat = sat_g[i];
- for (dimension_type j = sat_g.num_columns(); j-- > 0; )
- if (Scalar_Products::sign(tmp_con, gen_sys[j]) != tmp_sat[j]) {
+ for (dimension_type j = sat_g.num_columns(); j-- > 0; ) {
+ const bool sat_j = (Scalar_Products::sign(tmp_con, gen_sys[j]) == 0);
+ if (sat_j == tmp_sat[j]) {
#ifndef NDEBUG
cerr << "sat_g is declared up-to-date, but it is not!"
<< endl;
#endif
goto bomb;
}
+ }
}
if (has_pending_constraints()) {
More information about the PPL-devel
mailing list