GST_VALUE_HOLDS_... macros cause compilation warning -Waddress if GValue is allocated on stack
If GValue is allocated on stack, GST_VALUE_HOLDS_CAPS and other "HOLDS.." macros cause compilation warning -Waddress, because check for the pointer to not be NULL inside of the macro is always "true".
Let's put an example:
#include <gst/gst.h>
int main (int argc, char **argv)
{
GstTagList *list = NULL;
GValue v = { 0 };
/* Here we imagine that "list" is a real tag list */
gst_tag_list_copy_value (&v, list, "my-tag");
return GST_VALUE_HOLDS_CAPS (&v) ? 1 : 2;
}
compile:
$ gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
$ gcc test.c $(pkg-config --cflags --libs gstreamer-1.0) -Wall
In file included from /usr/include/gstreamer-1.0/gst/gstparamspecs.h:23:0,
from /usr/include/gstreamer-1.0/gst/gst.h:63,
from test.c:1:
test.c: In function ‘main’:
/usr/include/gstreamer-1.0/gst/gstvalue.h:145:46: warning: the comparison will always evaluate as ‘true’ for the address of ‘v’ will never be NULL [-Waddress]
#define GST_VALUE_HOLDS_CAPS(x) ((x) != NULL && G_VALUE_TYPE(x) == _gst_caps_type)
^
test.c:12:10: note: in expansion of macro ‘GST_VALUE_HOLDS_CAPS’
return GST_VALUE_HOLDS_CAPS (&v) ? 1 : 2;
^~~~~~~~~~~~~~~~~~~~
MR: !738 (diffs)