changeset 764:e1dfddeb801d

More synchronized error/debug methods * plugin/icedteanp/IcedTeaNPPlugin.cc: all occurrences of PLUGIN_ERROR_TWO and PLUGIN_ERROR_THREE replaced by PLUGIN_ERROR. PLUGIN_ERROR itself moved to * plugin/icedteanp/IcedTeaPluginUtils.h: (PLUGIN_ERROR) new fuction, now uses ... arguments and printf with __VA_ARGS__ instead of g_printerr
author Jiri Vanek <jvanek@redhat.com>
date Tue, 22 Oct 2013 11:46:27 +0200
parents eafa63cec4ca
children 175dda8f15e5
files ChangeLog plugin/icedteanp/IcedTeaNPPlugin.cc plugin/icedteanp/IcedTeaPluginUtils.h
diffstat 3 files changed, 41 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 21 13:19:26 2013 +0200
+++ b/ChangeLog	Tue Oct 22 11:46:27 2013 +0200
@@ -1,3 +1,12 @@
+2013-10-22  Jiri Vanek  <jvanek@redhat.com>
+
+	More synchronized error/debug methods
+	* plugin/icedteanp/IcedTeaNPPlugin.cc: all occurrences of  PLUGIN_ERROR_TWO
+	and  PLUGIN_ERROR_THREE replaced by PLUGIN_ERROR.  PLUGIN_ERROR itself moved 
+	to 
+	* plugin/icedteanp/IcedTeaPluginUtils.h: (PLUGIN_ERROR) new fuction, 
+	now uses ... arguments and printf with __VA_ARGS__ instead of g_printerr
+
 2013-10-21  Jiri Vanek  <jvanek@redhat.com>
 
 	Logic to extract main class attribute generalized to common methods.
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Mon Oct 21 13:19:26 2013 +0200
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Tue Oct 22 11:46:27 2013 +0200
@@ -56,19 +56,6 @@
 #include "IcedTeaNPPlugin.h"
 
 
-// Error reporting macros.
-#define PLUGIN_ERROR(message)                                       \
-  g_printerr ("%s:%d: thread %p: Error: %s\n", __FILE__, __LINE__,  \
-              g_thread_self (), message)
-
-#define PLUGIN_ERROR_TWO(first, second)                                 \
-  g_printerr ("%s:%d: thread %p: Error: %s: %s\n", __FILE__, __LINE__,  \
-              g_thread_self (), first, second)
-
-#define PLUGIN_ERROR_THREE(first, second, third)                        \
-  g_printerr ("%s:%d: thread %p: Error: %s: %s: %s\n", __FILE__,        \
-              __LINE__, g_thread_self (), first, second, third)
-
 // Plugin information passed to about:plugins.
 #define PLUGIN_FULL_NAME PLUGIN_NAME " (using " PLUGIN_VERSION ")"
 #define PLUGIN_DESC "The <a href=\"" PACKAGE_URL "\">" PLUGIN_NAME "</a> executes Java applets."
@@ -480,7 +467,7 @@
   PLUGIN_DEBUG ("ITNP_New: creating input fifo: %s\n", in_pipe_name);
   if (mkfifo (in_pipe_name, 0600) == -1 && errno != EEXIST)
     {
-      PLUGIN_ERROR_TWO ("Failed to create input pipe", strerror (errno));
+      PLUGIN_ERROR ("Failed to create input pipe", strerror (errno));
       np_error = NPERR_GENERIC_ERROR;
       goto cleanup_in_pipe_name;
     }
@@ -506,7 +493,7 @@
   PLUGIN_DEBUG ("ITNP_New: creating output fifo: %s\n", out_pipe_name);
   if (mkfifo (out_pipe_name, 0600) == -1 && errno != EEXIST)
     {
-      PLUGIN_ERROR_TWO ("Failed to create output pipe", strerror (errno));
+      PLUGIN_ERROR ("Failed to create output pipe", strerror (errno));
       np_error = NPERR_GENERIC_ERROR;
       goto cleanup_out_pipe_name;
     }
@@ -528,7 +515,7 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR_TWO ("Failed to create output channel",
+          PLUGIN_ERROR ("Failed to create output channel",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
@@ -555,7 +542,7 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR_TWO ("Failed to create input channel",
+          PLUGIN_ERROR ("Failed to create input channel",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
@@ -1020,7 +1007,7 @@
         {
           if (channel_error)
             {
-              PLUGIN_ERROR_TWO ("Failed to read line from input channel",
+              PLUGIN_ERROR ("Failed to read line from input channel",
                                 channel_error->message);
               g_error_free (channel_error);
               channel_error = NULL;
@@ -1359,7 +1346,7 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR_TWO ("Failed to spawn applet viewer",
+          PLUGIN_ERROR ("Failed to spawn applet viewer",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
@@ -1439,7 +1426,7 @@
     {
       if (channel_error)
         {
-          PLUGIN_ERROR_TWO ("Failed to spawn applet viewer",
+          PLUGIN_ERROR ("Failed to spawn applet viewer",
                             channel_error->message);
           g_error_free (channel_error);
           channel_error = NULL;
@@ -1570,7 +1557,7 @@
         {
           if (channel_error)
             {
-              PLUGIN_ERROR_TWO ("Failed to write bytes to output channel",
+              PLUGIN_ERROR ("Failed to write bytes to output channel",
                                 channel_error->message);
               g_error_free (channel_error);
               channel_error = NULL;
@@ -1584,7 +1571,7 @@
         {
           if (channel_error)
             {
-              PLUGIN_ERROR_TWO ("Failed to flush bytes to output channel",
+              PLUGIN_ERROR ("Failed to flush bytes to output channel",
                                 channel_error->message);
               g_error_free (channel_error);
               channel_error = NULL;
@@ -1651,7 +1638,7 @@
             {
               if (channel_error)
                 {
-                  PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
+                  PLUGIN_ERROR ("Failed to write shutdown message to"
                                     " appletviewer", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
@@ -1665,7 +1652,7 @@
             {
               if (channel_error)
                 {
-                  PLUGIN_ERROR_TWO ("Failed to write shutdown message to"
+                  PLUGIN_ERROR ("Failed to write shutdown message to"
                                     " appletviewer", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
@@ -1680,7 +1667,7 @@
             {
               if (channel_error)
                 {
-                  PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
+                  PLUGIN_ERROR ("Failed to shut down appletviewer"
                                     " output channel", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
@@ -1698,7 +1685,7 @@
             {
               if (channel_error)
                 {
-                  PLUGIN_ERROR_TWO ("Failed to shut down appletviewer"
+                  PLUGIN_ERROR ("Failed to shut down appletviewer"
                                     " input channel", channel_error->message);
                   g_error_free (channel_error);
                   channel_error = NULL;
@@ -1929,7 +1916,7 @@
       file_error = g_mkdir (data_directory.c_str(), 0700);
       if (file_error != 0)
         {
-          PLUGIN_ERROR_THREE ("Failed to create data directory",
+          PLUGIN_ERROR ("Failed to create data directory",
                           data_directory.c_str(),
                           strerror (errno));
           return NPERR_GENERIC_ERROR;
@@ -1941,7 +1928,7 @@
   if (!g_file_test (data_directory.c_str(),
                     (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)))
     {
-      PLUGIN_ERROR_THREE ("Temp directory does not exist: ",
+      PLUGIN_ERROR ("Temp directory does not exist: ",
                           data_directory.c_str(),
                           strerror (errno));
       return NPERR_GENERIC_ERROR;
--- a/plugin/icedteanp/IcedTeaPluginUtils.h	Mon Oct 21 13:19:26 2013 +0200
+++ b/plugin/icedteanp/IcedTeaPluginUtils.h	Tue Oct 22 11:46:27 2013 +0200
@@ -59,15 +59,24 @@
 #include <glib.h>
 #include <npruntime.h>
 
-#define PLUGIN_DEBUG(...) \
+#define PLUGIN_DEBUG(...)                                      \
+  do                                                           \
+  {                                                            \
+    if (plugin_debug)                                          \
+    {                                                          \
+      fprintf (stderr, "ITNPP Thread# %ld: ", pthread_self()); \
+      fprintf (stderr, __VA_ARGS__);                           \
+    }                                                          \
+  } while (0)
+  
+  // Error reporting macros.
+#define PLUGIN_ERROR(...)                                   \
   do                                                          \
-  {                                                           \
-    if (plugin_debug)                                         \
-    {                                                         \
-      fprintf (stderr, "ITNPP Thread# %ld: ", pthread_self()); \
-      fprintf (stderr, __VA_ARGS__);                          \
-    }                                                         \
-  } while (0)
+  {                                                         \
+        fprintf  (stderr, "%s:%d: thread %p: Error: %s\n",  \
+               __FILE__, __LINE__,                          \
+              g_thread_self (), __VA_ARGS__);               \
+   } while (0)
 
 #define CHECK_JAVA_RESULT(result_data)                               \
 {                                                                    \