From 391d9dfc9e3fdf857147206890809ed57de2bc16 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 3 Mar 2008 10:07:21 +0000 Subject: [PATCH] tests/check/gst/gststructure.c (GST_START_TEST): Add a check for the new warning. Original commit message from CVS: 2008-03-03 Andy Wingo * tests/check/gst/gststructure.c (GST_START_TEST): Add a check for the new warning. * gst/gststructure.c (gst_structure_from_string): Warn if structure_from_string didn't consume the whole string, but the caller did not provide an end pointer. --- ChangeLog | 9 +++++++++ common | 2 +- gst/gststructure.c | 3 +++ tests/check/gst/gststructure.c | 7 +++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8cdd684..c485618 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-03-03 Andy Wingo + + * tests/check/gst/gststructure.c (GST_START_TEST): Add a check for + the new warning. + + * gst/gststructure.c (gst_structure_from_string): Warn if + structure_from_string didn't consume the whole string, but the + caller did not provide an end pointer. + 2008-03-01 Tim-Philipp Müller Patch by: Fabrizio Gennari diff --git a/common b/common index 4fa1159..8ede243 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 4fa1159996900100f3a1cd3b43d7f0f027310cdb +Subproject commit 8ede243026af26e496d775b46ded7988ce883080 diff --git a/gst/gststructure.c b/gst/gststructure.c index c723585..18c816e 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -1966,6 +1966,9 @@ gst_structure_from_string (const gchar * string, gchar ** end) if (end) *end = (char *) string + (r - copy); + else if (*r) + g_warning ("gst_structure_from_string did not consume whole string," + " but caller did not provide end pointer (\"%s\")", string); g_free (copy); return structure; diff --git a/tests/check/gst/gststructure.c b/tests/check/gst/gststructure.c index c4b3ed7..6658ccb 100644 --- a/tests/check/gst/gststructure.c +++ b/tests/check/gst/gststructure.c @@ -126,6 +126,13 @@ GST_START_TEST (test_from_string) s = "***foo***, abc=(boolean)false"; structure = gst_structure_from_string (s, NULL); fail_unless (structure == NULL); + + /* assert that we get a warning if the structure wasn't entirely consumed, but + * we didn't provide an end pointer */ + s = "foo/bar; other random data"; + ASSERT_WARNING (structure = gst_structure_from_string (s, NULL)); + fail_if (structure == NULL, "Could not get structure from string %s", s); + gst_structure_free (structure); } GST_END_TEST; -- 2.7.4