summaryrefslogtreecommitdiff
path: root/gst/gsttracerrecord.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-03-02 10:37:09 +0200
committerSebastian Dröge <sebastian@centricular.com>2016-03-02 10:37:09 +0200
commitc904e00661004c3ecf83f86f284ff1d93a0deb14 (patch)
tree345fa9cddcd2f41022b05906afe02a107c1a33ed /gst/gsttracerrecord.c
parentc7734d2711da95baa3b924b68442f2bcb81a2c4e (diff)
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.
Diffstat (limited to 'gst/gsttracerrecord.c')
-rw-r--r--gst/gsttracerrecord.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/gst/gsttracerrecord.c b/gst/gsttracerrecord.c
index 9a99e23690..022f1694d2 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);