# HG changeset patch # User Jiri Vanek # Date 1382435187 -7200 # Node ID e1dfddeb801d564899c69661bceb49667fe5b6e9 # Parent eafa63cec4ca195e580f0edb7705f359bcf0b3be 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 diff -r eafa63cec4ca -r e1dfddeb801d ChangeLog --- 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 + + 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 Logic to extract main class attribute generalized to common methods. diff -r eafa63cec4ca -r e1dfddeb801d plugin/icedteanp/IcedTeaNPPlugin.cc --- 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 " PLUGIN_NAME " 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; diff -r eafa63cec4ca -r e1dfddeb801d plugin/icedteanp/IcedTeaPluginUtils.h --- 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 #include -#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) \ { \