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 745144 - gstvalue: Make sure GST_FOURCC_ARGS produces printable characters
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-25 07:28 UTC by Edward Hervey
Modified: 2015-02-26 06:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters (2.38 KB, patch)
2015-02-25 07:28 UTC, Edward Hervey
reviewed Details | Review
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters (2.38 KB, patch)
2015-02-25 16:31 UTC, Edward Hervey
committed Details | Review

Description Edward Hervey 2015-02-25 07:28:14 UTC
Make sure we only output printable characters with GST_FOURCC_ARGS
Comment 1 Edward Hervey 2015-02-25 07:28:20 UTC
Created attachment 297853 [details] [review]
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters

Some systems will crash if we use non-printable characters in print/debug
statements.

Make sure that GST_FOURCC_ARGS never does that
Comment 2 Tim-Philipp Müller 2015-02-25 10:48:28 UTC
Comment on attachment 297853 [details] [review]
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters

>-#define GST_FOURCC_ARGS(fourcc) \
>-        ((gchar) ((fourcc)     &0xff)), \
>-        ((gchar) (((fourcc)>>8 )&0xff)), \
>-        ((gchar) (((fourcc)>>16)&0xff)), \
>-        ((gchar) (((fourcc)>>24)&0xff))
>+
>+#define GST_PRINT_CHAR(fourcc, shift) \
>+  g_ascii_isprint((fourcc)>>shift) ? (fourcc)>>shift : '.'
>+#define GST_FOURCC_ARGS(fourcc)          \
>+    GST_PRINT_CHAR(fourcc, 0),           \
>+    GST_PRINT_CHAR(fourcc, 8),           \
>+    GST_PRINT_CHAR(fourcc, 16),          \
>+    GST_PRINT_CHAR(fourcc, 24)

To me, passing the shift argument to GST_PRINT_CHAR seems a bit weird. If you're making this a publically usable define with the name _CHAR in it, it should just take a single char/uchar IMHO. We also seem to be dropping the explicit &0xff which I think would be good to keep.
Comment 3 Edward Hervey 2015-02-25 16:10:23 UTC
I was just trying to avoid a double shift/eval on each variable.

I don't really need to make the _CHAR macro public, but didn't want to make the GST_FOURCC_ARGS macro humongous
Comment 4 Edward Hervey 2015-02-25 16:31:33 UTC
Created attachment 297898 [details] [review]
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters

Some systems will crash if we use non-printable characters in print/debug
statements.

Make sure that GST_FOURCC_ARGS never does that
Comment 5 Tim-Philipp Müller 2015-02-25 17:09:01 UTC
Comment on attachment 297898 [details] [review]
gstvalue: Make sure GST_FOURCC_ARGS produces printable characters

Looks good to me. I don't think this is a place where we need to worry about the performance impact of bit shifting :)

Perhaps the helper macro should still have a __GST_* prefix just to be safe(r)?
Comment 6 Edward Hervey 2015-02-26 06:49:52 UTC
Thanks for the review

Pushed a version with __GST_PRINT_CHAR instead

commit 075def0f9771dd89503808e7d18f0569f7a76690
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Wed Feb 25 08:26:19 2015 +0100

    gstvalue: Make sure GST_FOURCC_ARGS produces printable characters
    
    Some systems will crash if we use non-printable characters in print/debug
    statements.
    
    Make sure that GST_FOURCC_ARGS never does that
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745144