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

Gedare Bloom gedare at rtems.org
Tue Jun 29 17:14:45 UTC 2021


On Tue, Jun 29, 2021 at 11:12 AM Gedare Bloom <gedare at rtems.org> wrote:
>
> 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) {
squash your whitespace change from patch 2/2 into this commit.

> > +    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