[GIT] ppl/ppl(master): Magic constants avoided.

Module: ppl/ppl Branch: master Commit: f768b3933ef890976ed57198e99fbe90885fb533 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=f768b3933ef89...
Author: Roberto Bagnara bagnara@cs.unipr.it Date: Sun Oct 9 19:45:03 2011 +0200
Magic constants avoided. Detected by ECLAIR service nomagicc.
---
demos/ppl_lcdd/ppl_lcdd.cc | 17 ++++++++++------- demos/ppl_pips/ppl_pips.cc | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/demos/ppl_lcdd/ppl_lcdd.cc b/demos/ppl_lcdd/ppl_lcdd.cc index 68e6f53..b48962d 100644 --- a/demos/ppl_lcdd/ppl_lcdd.cc +++ b/demos/ppl_lcdd/ppl_lcdd.cc @@ -415,13 +415,16 @@ process_options(int argc, char* argv[]) { #endif // defined(PPL_LCDD_SUPPORTS_LIMIT_ON_CPU_TIME)
case 'R': - l = strtol(optarg, &endptr, 10); - if (*endptr || l < 0) - fatal("a non-negative integer must follow `-R'"); - else if (((unsigned long) l) > ULONG_MAX/(1024*1024)) - max_bytes_of_virtual_memory = ULONG_MAX; - else - max_bytes_of_virtual_memory = l*1024*1024; + { + const int MEGA = 1024*1024; + l = strtol(optarg, &endptr, 10); + if (*endptr || l < 0) + fatal("a non-negative integer must follow `-R'"); + else if (static_cast<unsigned long>(l) > ULONG_MAX/MEGA) + max_bytes_of_virtual_memory = ULONG_MAX; + else + max_bytes_of_virtual_memory = l*MEGA; + } break;
case 'o': diff --git a/demos/ppl_pips/ppl_pips.cc b/demos/ppl_pips/ppl_pips.cc index 69f2f8a..3b2c193 100644 --- a/demos/ppl_pips/ppl_pips.cc +++ b/demos/ppl_pips/ppl_pips.cc @@ -673,13 +673,16 @@ process_options(int argc, char* argv[]) { break;
case 'R': - l = strtol(optarg, &endptr, 10); - if (*endptr || l < 0) - fatal("a non-negative integer must follow `-R'"); - else if (((unsigned long) l) > ULONG_MAX/(1024*1024)) - max_bytes_of_virtual_memory = ULONG_MAX; - else - max_bytes_of_virtual_memory = l*1024*1024; + { + const int MEGA = 1024*1024; + l = strtol(optarg, &endptr, 10); + if (*endptr || l < 0) + fatal("a non-negative integer must follow `-R'"); + else if (static_cast<unsigned long>(l) > ULONG_MAX/MEGA) + max_bytes_of_virtual_memory = ULONG_MAX; + else + max_bytes_of_virtual_memory = l*MEGA; + } break;
case 'o':
participants (1)
-
Roberto Bagnara