[PATCH v1 1/2] ReportsBase.cc: Remove possible division by zero

Ryan Long ryan.long at oarcorp.com
Tue Jun 29 17:26:08 UTC 2021


No good reason. I'll make those changes and send V2.

-----Original Message-----
From: Gedare Bloom <gedare at rtems.org> 
Sent: Tuesday, June 29, 2021 12:13 PM
To: Ryan Long <ryan.long at oarcorp.com>
Cc: devel at rtems.org
Subject: Re: [PATCH v1 1/2] ReportsBase.cc: Remove possible division by zero

On Tue, Jun 29, 2021 at 11:06 AM Ryan Long <ryan.long at oarcorp.com> wrote:
>
> CID 1503709: Division or modulo by float zero
>
> Closes #4415
> ---
>  tester/covoar/ReportsBase.cc | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tester/covoar/ReportsBase.cc 
> b/tester/covoar/ReportsBase.cc index b4a755c..31dc429 100644
> --- a/tester/covoar/ReportsBase.cc
> +++ b/tester/covoar/ReportsBase.cc
> @@ -482,9 +482,13 @@ void  ReportsBase::WriteSummaryReport(
>      }
>    }
>
> -  percentage = (double) notExecuted;
> -  percentage /= (double) totalBytes;
> -  percentage *= 100.0;
> +  if (totalBytes == 0) {
> +    percentage = 0;
> +  } else {
> +    percentage = (double) notExecuted;
> +    percentage /= (double) totalBytes;
> +    percentage *= 100.0;
ok, any good reason not to use one line? Just curious.
percentage = 100.0 * (double) notExecuted / totalBytes;

> +  }
>
>    percentageBranches = (double) (
>      SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) +
> --
> 1.8.3.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list