[libdca-devel] [PATCH 1/2] test/compare: fix division by zero
Timothy Gu
timothygu99 at gmail.com
Wed Dec 18 06:14:52 CET 2013
Also extend errors.
Fixes Coverity CID 1137695.
Signed-off-by: Timothy Gu <timothygu99 at gmail.com>
---
test/compare.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/compare.c b/test/compare.c
index d44448c..dfa2be3 100644
--- a/test/compare.c
+++ b/test/compare.c
@@ -61,7 +61,7 @@ int main (int argc, char ** argv)
}
total += 512;
}
- if (i == j) {
+ if (i == j && total != 0) {
err /= total;
square = (square / total) - (err * err);
if (square > 0)
@@ -72,9 +72,9 @@ int main (int argc, char ** argv)
max, err, square);
return ((max > 0.01) || (err > 0.001) || (square > 0.001));
}
- if (i < j)
+ if (i < j || i < 512)
printf ("%s is too short\n", argv[1]);
- else
+ if (j < i || j < 512)
printf ("%s is too short\n", argv[2]);
return 1;
}
--
1.8.3.2
More information about the libdca-devel
mailing list