From: Sebastian Dröge Date: Wed, 2 Mar 2016 08:37:09 +0000 (+0200) Subject: tracerrecord: Remove useless NULL check and add assertion for making assumptions... X-Git-Tag: 1.10.4~368 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c904e00661004c3ecf83f86f284ff1d93a0deb14;p=platform%2Fupstream%2Fgstreamer.git tracerrecord: Remove useless NULL check and add assertion for making assumptions explicit gst_structure_new_empty() is not returning NULL in any valid scenarios, checking for NULL here is useless. Especially because we would dereference any NULL right after the NULL check again. CID 1352037. We previously check if the string ends on .class, as such strrchr() should return something non-NULL. Add an assertion for that. CID 1349642. --- diff --git a/gst/gsttracerrecord.c b/gst/gsttracerrecord.c index 9a99e23..022f169 100644 --- a/gst/gsttracerrecord.c +++ b/gst/gsttracerrecord.c @@ -112,6 +112,7 @@ gst_tracer_record_build_format (GstTracerRecord * self) /* cut off '.class' suffix */ name = g_strdup (name); p = strrchr (name, '.'); + g_assert (p != NULL); *p = '\0'; s = g_string_sized_new (STRUCTURE_ESTIMATED_STRING_LEN (structure)); @@ -186,37 +187,35 @@ gst_tracer_record_new (const gchar * name, const gchar * firstfield, ...) GstTracerRecord *self; GstStructure *structure; va_list varargs; + gchar *err = NULL; + GType type; + GQuark id; va_start (varargs, firstfield); structure = gst_structure_new_empty (name); - if (structure) { - gchar *err = NULL; - GType type; - GQuark id; - - while (firstfield) { - GValue val = { 0, }; - - id = g_quark_from_string (firstfield); - type = va_arg (varargs, GType); - - /* all fields passed here must be GstStructures which we take over */ - if (type != GST_TYPE_STRUCTURE) { - GST_WARNING ("expected field of type GstStructure, but %s is %s", - firstfield, g_type_name (type)); - } - - G_VALUE_COLLECT_INIT (&val, type, varargs, G_VALUE_NOCOPY_CONTENTS, &err); - if (G_UNLIKELY (err)) { - g_critical ("%s", err); - break; - } - /* see boxed_proxy_collect_value */ - val.data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS; - gst_structure_id_take_value (structure, id, &val); - - firstfield = va_arg (varargs, gchar *); + + while (firstfield) { + GValue val = { 0, }; + + id = g_quark_from_string (firstfield); + type = va_arg (varargs, GType); + + /* all fields passed here must be GstStructures which we take over */ + if (type != GST_TYPE_STRUCTURE) { + GST_WARNING ("expected field of type GstStructure, but %s is %s", + firstfield, g_type_name (type)); } + + G_VALUE_COLLECT_INIT (&val, type, varargs, G_VALUE_NOCOPY_CONTENTS, &err); + if (G_UNLIKELY (err)) { + g_critical ("%s", err); + break; + } + /* see boxed_proxy_collect_value */ + val.data[1].v_uint &= ~G_VALUE_NOCOPY_CONTENTS; + gst_structure_id_take_value (structure, id, &val); + + firstfield = va_arg (varargs, gchar *); } va_end (varargs);