From: Edward Hervey Date: Tue, 10 Dec 2013 22:53:24 +0000 (-0500) Subject: gstvalue: Fix comparision of double range X-Git-Tag: 1.3.1~283 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ea6b04c10b10fde9d62190068f274b940edef07;p=platform%2Fupstream%2Fgstreamer.git 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 --- 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);