codecanalyzer: do not use g_error if abort is not desired
authorReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
Thu, 28 Jan 2016 22:48:17 +0000 (14:48 -0800)
committerReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>
Fri, 29 Jan 2016 22:37:13 +0000 (14:37 -0800)
Use g_printerr() instead.

g_error() calls abort after outputting the message
so these blocks' return statements and free()s
were unreachable.

Aditionally, fix wrong void returns on non-void
function, drop trailing whitespace before newline and
add \n's as needed (default handler won't add one).

codecanalyzer/src/codecanalyzer.c
codecanalyzer/src/gst_analyzer.c
codecanalyzer/src/plugins/gst/analyzersink/mpeg_xml.c
codecanalyzer/src/xml_parse.c

index 061d80629938b31a50ba9ebe095716c51d7f6cbb..a835876714d93d346290c9c78e8d91fb110edf27 100644 (file)
@@ -29,6 +29,7 @@
 #include <libxml/parser.h>
 #include <gtk/gtk.h>
 
+#include <glib.h>
 #include <glib/gprintf.h>
 
 #include "gst_analyzer.h"
@@ -1034,13 +1035,13 @@ main (int argc, char *argv[])
 
   ret = analyzer_ui_init ();
   if (!ret) {
-    g_error ("Failed to activate the gtk+-3.x backend \n");
+    g_printerr ("Failed to activate the gtk+-3.x backend\n");
     goto done;
   }
 
   ret = analyzer_create_dirs ();
   if (!ret) {
-    g_error ("Failed to create the necessary dir names \n");
+    g_printerr ("Failed to create the necessary dir names\n");
     goto done;
   }
 
index c7cf35d09c9d49fbf47065a6a9067b877ebe9fba..f5fee9bf33e2128a6e570749f6a18f55cd096a7f 100644 (file)
@@ -187,7 +187,7 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data)
   } else if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
     GError *error = NULL;
     gst_message_parse_error (message, &error, NULL);
-    g_error ("gstreamer error : %s", error->message);
+    g_printerr ("gstreamer error : %s\n", error->message);
     g_error_free (error);
     return FALSE;
   }
@@ -264,7 +264,7 @@ gst_analyzer_init (GstAnalyzer * analyzer, char *uri)
     gst_init (NULL, NULL);
 
   if (!analyzer_sink_register_static ()) {
-    g_error ("Failed to register static plugins.... \n");
+    g_printerr ("Failed to register static plugins....\n");
     status = GST_ANALYZER_STATUS_CODEC_PARSER_MISSING;
     goto error;
   }
@@ -303,7 +303,7 @@ gst_analyzer_init (GstAnalyzer * analyzer, char *uri)
   analyzer->pipeline = gst_pipeline_new ("pipeline");
 
   if (!analyzer->src || !analyzer->parser || !analyzer->sink) {
-    g_error ("Failed to create the necessary gstreamer elements..");
+    g_printerr ("Failed to create the necessary gstreamer elements..\n");
     status = GST_ANALYZER_STATUS_ERROR_UNKNOWN;
     goto error;
   }
index adfd7effc964fcd185b62addac4fd7473a85dbc8..e97efc4d6646cecab6749ea44c5b8cc0368bfe85 100644 (file)
@@ -21,6 +21,7 @@
 #include "mpeg_xml.h"
 #include "xml_utils.h"
 
+#include <glib.h>
 
 static gboolean
 create_seq_hdr_xml (xmlTextWriterPtr writer, GstMpegVideoSequenceHdr * seq_hdr)
@@ -423,7 +424,7 @@ analyzer_create_mpeg2video_frame_xml (GstMpegVideoMeta * mpeg_meta,
 
   if (xmlTextWriterWriteComment (writer,
           (xmlChar *) "Data parssed from the mpeg2 stream") < 0) {
-    g_error ("Error: Failed to write the comment \n");
+    g_printerr ("Error: Failed to write the comment\n");
     return FALSE;
   }
 
@@ -532,12 +533,12 @@ analyzer_create_mpeg2video_frame_xml (GstMpegVideoMeta * mpeg_meta,
   }
 #endif
   if (xmlTextWriterEndElement (writer) < 0) {
-    g_error ("Error: Failed to end mpeg2 root element \n");
+    g_printerr ("Error: Failed to end mpeg2 root element\n");
     return FALSE;
   }
 
   if (xmlTextWriterEndDocument (writer) < 0) {
-    g_error ("Error: Ending document \n");
+    g_printerr ("Error: Ending document\n");
     return FALSE;
   }
 
index f6800fc7b5444ac43774a3380f4bfc66599387f7..adb31f7a0f1f5ab073f22cc1ee7eadfcf33de51b 100644 (file)
@@ -19,6 +19,8 @@
  */
 #include "xml_parse.h"
 
+#include <glib.h>
+
 void
 analyzer_node_list_free (GList * list)
 {
@@ -62,13 +64,13 @@ analyzer_get_list_header_strings (char *file_name)
 
   doc = xmlParseFile (file_name);
   if (!doc) {
-    g_error ("Failed to do xmlParseFile for the file.. %s\n", file_name);
+    g_printerr ("Failed to do xmlParseFile for the file.. %s\n", file_name);
     goto error;
   }
 
   cur = xmlDocGetRootElement (doc);
   if (cur == NULL) {
-    g_error ("empty document\n");
+    g_printerr ("empty document\n");
     xmlFreeDoc (doc);
     goto error;
   }
@@ -76,7 +78,7 @@ analyzer_get_list_header_strings (char *file_name)
   if (xmlStrcmp (cur->name, (const xmlChar *) "mpeg2") &&
       xmlStrcmp (cur->name, (const xmlChar *) "h264") &&
       xmlStrcmp (cur->name, (const xmlChar *) "h265")) {
-    g_error ("document of the wrong type !!");
+    g_printerr ("document of the wrong type !!\n");
     xmlFreeDoc (doc);
     goto error;
   }
@@ -105,22 +107,23 @@ analyzer_get_list_analyzer_node_from_xml (char *file_name, char *node_name)
 
   doc = xmlParseFile (file_name);
   if (!doc) {
-    g_error ("Failed to do xmlParseFile for the file.. %s\n", file_name);
+    g_printerr ("Failed to do xmlParseFile for the file.. %s\n", file_name);
+    goto error;
   }
 
   cur = xmlDocGetRootElement (doc);
   if (cur == NULL) {
-    g_error ("empty document\n");
     xmlFreeDoc (doc);
-    return;
+    g_printerr ("empty document\n");
+    goto error;
   }
 
   if (xmlStrcmp (cur->name, (const xmlChar *) "mpeg2") &&
       xmlStrcmp (cur->name, (const xmlChar *) "h264") &&
       xmlStrcmp (cur->name, (const xmlChar *) "h265")) {
-    g_error ("document of the wrong type !!");
     xmlFreeDoc (doc);
-    return;
+    g_printerr ("document of the wrong type !!\n");
+    goto error;
   }
 
   tmp = cur->xmlChildrenNode;
@@ -179,4 +182,7 @@ analyzer_get_list_analyzer_node_from_xml (char *file_name, char *node_name)
     list = g_list_reverse (list);
 
   return list;
+
+error:
+  return NULL;
 }