After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 794355 - gst_structure_to_string: display actual value of pointers
gst_structure_to_string: display actual value of pointers
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-03-15 11:45 UTC by Guillaume Desmottes
Modified: 2018-06-15 10:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gst_structure_to_string: display actual value of pointers (1.58 KB, patch)
2018-03-15 11:46 UTC, Guillaume Desmottes
none Details | Review
gst_structure_to_string: display actual value of pointers (2.24 KB, patch)
2018-04-06 13:55 UTC, Guillaume Desmottes
none Details | Review
gst_structure_to_string: display actual value of pointers (2.24 KB, patch)
2018-06-11 07:53 UTC, Guillaume Desmottes
none Details | Review
gst_structure_to_string: display actual value of pointers (2.36 KB, patch)
2018-06-15 09:38 UTC, Guillaume Desmottes
committed Details | Review

Description Guillaume Desmottes 2018-03-15 11:45:55 UTC
As discussed on bug #794331 it's pretty confusing to always display "NULL" when serializing G_TYPE_POINTER fields regardless of their actual value.
Comment 1 Guillaume Desmottes 2018-03-15 11:46:12 UTC
Created attachment 369729 [details] [review]
gst_structure_to_string: display actual value of pointers

We used to always display "NULL" which was pretty confusing when
debugging.
Comment 2 Guillaume Desmottes 2018-03-15 11:47:23 UTC
Review of attachment 369729 [details] [review]:

::: gst/gststructure.c
@@ +1833,2 @@
     } else {
+      if (!G_TYPE_CHECK_VALUE_TYPE (&field->value, G_TYPE_STRING))

I'm not sure why we special case strings here as they are supposed to be serialized by gst_value_serialize().
Comment 3 Tim-Philipp Müller 2018-04-06 11:52:50 UTC
I was wondering about that part as well (G_TYPE_STRING).

I would like a unit test to go with this that makes sure that we don't deserialize these pointer values.
Comment 4 Guillaume Desmottes 2018-04-06 13:55:37 UTC
Created attachment 370584 [details] [review]
gst_structure_to_string: display actual value of pointers

We used to always display "NULL" which was pretty confusing when
debugging.
Comment 5 Guillaume Desmottes 2018-06-11 07:53:47 UTC
Created attachment 372630 [details] [review]
gst_structure_to_string: display actual value of pointers

We used to always display "NULL" which was pretty confusing when
debugging.
Comment 6 Guillaume Desmottes 2018-06-11 07:54:15 UTC
Rebased.
Is this good to go?
Comment 7 Tim-Philipp Müller 2018-06-11 08:20:35 UTC
Comment on attachment 372630 [details] [review]
gst_structure_to_string: display actual value of pointers

I think this is good to go, but I'm not sure about the unit test:

>--- a/tests/check/gst/gststructure.c
>+++ b/tests/check/gst/gststructure.c
>@@ -274,6 +274,18 @@ GST_START_TEST (test_to_from_string)
> 
>   gst_structure_free (st1);
>   gst_structure_free (st2);
>+
>+  /* pointers are serialized but not deserialized */
>+  st1 = gst_structure_new ("test", "ptr", G_TYPE_POINTER, 0xdeadbeef, NULL);
>+  str = gst_structure_to_string (st1);
>+  fail_unless (strcmp (str, "test, ptr=(gpointer)0xdeadbeef;") == 0,
>+      "Failed to serialize to right string: %s", str);

I'm not sure if we can assume that g_string_append_printf() will yield the exact same string on every system. Unless we know it will always end up in an internal glib printf implementation and never a system printf. e.g. it could be 0xDEADBEEF on some systems, or maybe an extra prefix or so. I don't know if the C standard specifies exactly how this must be printed - did you check?
Comment 8 Guillaume Desmottes 2018-06-15 09:37:54 UTC
Good point, it's indeed platform specific: https://gitlab.gnome.org/GNOME/glib/blob/master/glib/gprintf.c#L315

I relaxed the check in the test.
Comment 9 Guillaume Desmottes 2018-06-15 09:38:09 UTC
Created attachment 372689 [details] [review]
gst_structure_to_string: display actual value of pointers

We used to always display "NULL" which was pretty confusing when
debugging.
Comment 10 Tim-Philipp Müller 2018-06-15 10:01:02 UTC
Comment on attachment 372689 [details] [review]
gst_structure_to_string: display actual value of pointers

Thanks!
Comment 11 Guillaume Desmottes 2018-06-15 10:05:43 UTC
Attachment 372689 [details] pushed as 6dba0d9 - gst_structure_to_string: display actual value of pointers