dee

Merge lp:~charlesk/dee/fix-904995 into lp:dee

Proposed by Charles Kerr
Status: Needs review
Proposed branch: lp:~charlesk/dee/fix-904995
Merge into: lp:dee
Diff against target: 45 lines (+22/-13)
1 file modified
tests/test-benchmark.c (+22/-13)
To merge this branch: bzr merge lp:~charlesk/dee/fix-904995
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Francis Ginther Pending
Review via email: mp+210897@code.launchpad.net

Commit message

Fix a potential divide-by-zero error detected by Coverity.

Description of the change

Fix (or, rather, silence) a potential divide-by-zero error detected by Coverity.

This patch fell behind the couch cushions awhile back, but I was cleaning out my branches and found it... good thing it's not an important bug.

To post a comment you must log in.
lp:~charlesk/dee/fix-904995 updated
345. By Charles Kerr

sync with lp:dee

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

345. By Charles Kerr

sync with lp:dee

344. By Charles Kerr

silence an improbable div-by-zero coverity warning (bug #904995)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/test-benchmark.c'
--- tests/test-benchmark.c 2013-02-04 16:07:59 +0000
+++ tests/test-benchmark.c 2014-03-13 20:34:20 +0000
@@ -80,19 +80,28 @@
80 if (bench->state == NULL)80 if (bench->state == NULL)
81 bench->benchmark_setup (bench);81 bench->benchmark_setup (bench);
82 }82 }
83 83
84 /* Compute average runtime */84 if (bench->n_runs == 0)
85 avg_runtime = total_runtime / bench->n_runs;85 {
86 86 avg_runtime = 0;
87 /* Compute standard deviation */87 std_dev = 0;
88 std_dev = 0;88 coeff_of_var = 0;
89 for (i = 0; i < bench->n_runs; i++)89 }
90 {90 else
91 gdouble delta = bench->runs[i].elapsed - avg_runtime;91 {
92 std_dev += delta * delta;92 /* Compute average runtime */
93 }93 avg_runtime = total_runtime / bench->n_runs;
94 std_dev = sqrt (std_dev / bench->n_runs);94
95 coeff_of_var = (std_dev /avg_runtime) * 100;95 /* Compute standard deviation */
96 std_dev = 0;
97 for (i = 0; i < bench->n_runs; i++)
98 {
99 gdouble delta = bench->runs[i].elapsed - avg_runtime;
100 std_dev += delta * delta;
101 }
102 std_dev = sqrt (std_dev / bench->n_runs);
103 coeff_of_var = (std_dev /avg_runtime) * 100;
104 }
96 105
97 /* This is not a very precise way of judging the quality,106 /* This is not a very precise way of judging the quality,
98 * but better than rigorous hand waving */107 * but better than rigorous hand waving */

Subscribers

People subscribed via source and target branches

to all changes: