[PPL-devel] [GIT] ppl/ppl(master): Avoid mixing boolean and arithmetic values.
Enea Zaffanella
zaffanella at cs.unipr.it
Sun Feb 26 14:23:27 CET 2012
Module: ppl/ppl
Branch: master
Commit: 787dc72b55dd658b8e630e3d2eeb3cf7434c1f5d
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=787dc72b55dd658b8e630e3d2eeb3cf7434c1f5d
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Sun Feb 26 14:11:30 2012 +0100
Avoid mixing boolean and arithmetic values.
Detected by ECLAIR service utypflag.
---
src/Interval_Info.defs.hh | 2 +-
src/Pointset_Powerset.templates.hh | 16 ++++++++--------
src/checked_int.inlines.hh | 22 ++++++++++++----------
3 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/src/Interval_Info.defs.hh b/src/Interval_Info.defs.hh
index 95d91d9..04fb3e9 100644
--- a/src/Interval_Info.defs.hh
+++ b/src/Interval_Info.defs.hh
@@ -75,7 +75,7 @@ set_bit(T& bits, unsigned int bit, bool value) {
template <typename T>
inline bool
get_bit(const T& bits, unsigned int bit) {
- return bits & (static_cast<T>(1) << bit);
+ return (bits & (static_cast<T>(1) << bit)) != 0;
}
template <typename T>
diff --git a/src/Pointset_Powerset.templates.hh b/src/Pointset_Powerset.templates.hh
index 76c1b9b..f2cb3c7 100644
--- a/src/Pointset_Powerset.templates.hh
+++ b/src/Pointset_Powerset.templates.hh
@@ -925,13 +925,13 @@ Pointset_Powerset<PSET>::maximize(const Linear_Expression& expr,
PPL_DIRTY_TEMP_COEFFICIENT(best_sup_d);
best_sup_n = 0;
best_sup_d = 1;
- bool best_max = 0;
+ bool best_max = false;
PPL_DIRTY_TEMP_COEFFICIENT(iter_sup_n);
PPL_DIRTY_TEMP_COEFFICIENT(iter_sup_d);
iter_sup_n = 0;
iter_sup_d = 1;
- bool iter_max = 0;
+ bool iter_max = false;
PPL_DIRTY_TEMP_COEFFICIENT(tmp);
@@ -981,14 +981,14 @@ Pointset_Powerset<PSET>::maximize(const Linear_Expression& expr,
PPL_DIRTY_TEMP_COEFFICIENT(best_sup_d);
best_sup_n = 0;
best_sup_d = 1;
- bool best_max = 0;
+ bool best_max = false;
Generator best_g = point();
PPL_DIRTY_TEMP_COEFFICIENT(iter_sup_n);
PPL_DIRTY_TEMP_COEFFICIENT(iter_sup_d);
iter_sup_n = 0;
iter_sup_d = 1;
- bool iter_max = 0;
+ bool iter_max = false;
Generator iter_g = point();
PPL_DIRTY_TEMP_COEFFICIENT(tmp);
@@ -1044,13 +1044,13 @@ Pointset_Powerset<PSET>::minimize(const Linear_Expression& expr,
PPL_DIRTY_TEMP_COEFFICIENT(best_inf_d);
best_inf_n = 0;
best_inf_d = 1;
- bool best_min = 0;
+ bool best_min = false;
PPL_DIRTY_TEMP_COEFFICIENT(iter_inf_n);
PPL_DIRTY_TEMP_COEFFICIENT(iter_inf_d);
iter_inf_n = 0;
iter_inf_d = 1;
- bool iter_min = 0;
+ bool iter_min = false;
PPL_DIRTY_TEMP_COEFFICIENT(tmp);
@@ -1100,14 +1100,14 @@ Pointset_Powerset<PSET>::minimize(const Linear_Expression& expr,
PPL_DIRTY_TEMP_COEFFICIENT(best_inf_d);
best_inf_n = 0;
best_inf_d = 1;
- bool best_min = 0;
+ bool best_min = false;
Generator best_g = point();
PPL_DIRTY_TEMP_COEFFICIENT(iter_inf_n);
PPL_DIRTY_TEMP_COEFFICIENT(iter_inf_d);
iter_inf_n = 0;
iter_inf_d = 1;
- bool iter_min = 0;
+ bool iter_min = false;
Generator iter_g = point();
PPL_DIRTY_TEMP_COEFFICIENT(tmp);
diff --git a/src/checked_int.inlines.hh b/src/checked_int.inlines.hh
index bd31616..0a8175b 100644
--- a/src/checked_int.inlines.hh
+++ b/src/checked_int.inlines.hh
@@ -76,16 +76,18 @@ struct Extended_Int {
: C_Integer<Type>::min);
static const Type not_a_number
= ((C_Integer<Type>::min >= 0)
- ? (C_Integer<Type>::max - Policy::has_infinity * 2)
- : (C_Integer<Type>::min + Policy::has_infinity));
- static const Type min = (C_Integer<Type>::min
- + ((C_Integer<Type>::min >= 0)
- ? 0
- : (Policy::has_infinity + Policy::has_nan)));
- static const Type max = (C_Integer<Type>::max
- - ((C_Integer<Type>::min >= 0)
- ? (2*Policy::has_infinity + Policy::has_nan)
- : Policy::has_infinity));
+ ? (C_Integer<Type>::max - 2 * (Policy::has_infinity ? 1 : 0))
+ : (C_Integer<Type>::min + (Policy::has_infinity ? 1 : 0)));
+ static const Type min
+ = (C_Integer<Type>::min
+ + ((C_Integer<Type>::min >= 0)
+ ? 0
+ : ((Policy::has_infinity ? 1 : 0) + (Policy::has_nan ? 1 : 0))));
+ static const Type max
+ = (C_Integer<Type>::max
+ - ((C_Integer<Type>::min >= 0)
+ ? (2 * (Policy::has_infinity ? 1 : 0) + (Policy::has_nan ? 1 : 0))
+ : (Policy::has_infinity ? 1 : 0)));
};
template <typename Policy, typename To>
More information about the PPL-devel
mailing list