From 3ea6b04c10b10fde9d62190068f274b940edef07 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Tue, 10 Dec 2013 17:53:24 -0500 Subject: [PATCH] gstvalue: Fix comparision of double range Checking twice the lower bound is great (you never know, it might change between the two calls by someone using emacs butterfly-mode), but it's a bit more useful to check the higher bound are also identical. Detected by Coverity --- gst/gstvalue.c | 2 +- tests/check/gst/gstvalue.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 3138a19..528932d 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -1522,7 +1522,7 @@ static gint gst_value_compare_double_range (const GValue * value1, const GValue * value2) { if (value2->data[0].v_double == value1->data[0].v_double && - value2->data[0].v_double == value1->data[0].v_double) + value2->data[1].v_double == value1->data[1].v_double) return GST_VALUE_EQUAL; return GST_VALUE_UNORDERED; } diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c index fcb7220..5f1b347 100644 --- a/tests/check/gst/gstvalue.c +++ b/tests/check/gst/gstvalue.c @@ -1475,6 +1475,26 @@ GST_START_TEST (test_value_subtract_double) /* double_range <-> double_range */ + /* Check equality */ + g_value_init (&src1, GST_TYPE_DOUBLE_RANGE); + gst_value_set_double_range (&src1, 10.0, 20.0); + g_value_init (&src2, GST_TYPE_DOUBLE_RANGE); + gst_value_set_double_range (&src2, 10.0, 15.0); + /* They are not equal (higher bound is different */ + fail_if (gst_value_compare (&src1, &src2) == GST_VALUE_EQUAL); + g_value_unset (&src1); + /* They are not equal (lower bound is different */ + g_value_init (&src1, GST_TYPE_DOUBLE_RANGE); + gst_value_set_double_range (&src1, 5.0, 15.0); + fail_if (gst_value_compare (&src1, &src2) == GST_VALUE_EQUAL); + g_value_unset (&src1); + /* And finally check equality */ + g_value_init (&src1, GST_TYPE_DOUBLE_RANGE); + gst_value_set_double_range (&src1, 10.0, 15.0); + fail_unless (gst_value_compare (&src1, &src2) == GST_VALUE_EQUAL); + g_value_unset (&src1); + g_value_unset (&src2); + /* same range, empty set */ g_value_init (&src1, GST_TYPE_DOUBLE_RANGE); gst_value_set_double_range (&src1, 10.0, 20.0); -- 2.7.4