[ltt-dev] A stdout/stderr bug in an LTTng agent TCF plug-in (client/lttctlclient.c)?

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Thu Jul 21 09:14:17 EDT 2011


   Is there any particular reason why the LTTng client TCF plug-in (git.dorsal.polymtl.ca: lttng-agent-72ea7d0, client/lttctlclient.c) prints out some of its "error" messages to stdout and most others to stderr?  The fix consists in changing the statements that read:

 

        printf("Error: ...

 

into:

 

        fprintf(stderr, "Error: ...

 

   The diff is (I've included a few editorial tweaks as well, mostly fixing French punctuation masquerading as English punctuation):

________________________________

--- a/client/lttctlclient.c                2011-03-23 16:20:41.000000000 -0400

+++ b/client/lttctlclient.c             2011-07-21 09:10:56.710603623 -0400

@@ -126,9 +126,9 @@

             }

         }

     }

-    fprintf(stderr, "lttctlclient error : The trace identified by : %s->"

+    fprintf(stderr, "lttctl_client error: The trace channel identified by: %s->"

             "%s->%s->%s was never started by this agent but we have just"

-            "received data for it.\nIs the provider respecting the standard?",

+            "received data for it.\nIs the provider complying with the standard?",

             provider, target, trace, channel);

     return NULL;

 }

@@ -175,7 +175,7 @@

         if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);

         clear_trap(&trap);

     }

-    /* fprintf(stderr, "lttctlclient : Just got event data!\n"); */

+    /* fprintf(stderr, "lttctl_client: Just got event data!\n"); */

 

 clean:

     free(provider);

@@ -280,10 +280,10 @@

         if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);

 

         if (destroy_trace(provider, target, trace))

-            fprintf(stderr, "lttctlclient : Couldn't destroy the trace : %s->"

+            fprintf(stderr, "lttctl_client: Couldn't destroy the trace: %s->"

                     "%s->%s\n", provider, target, trace);

         else

-            fprintf(stderr, "lttctlclient : trace : %s->%s->%s is done\n",

+            fprintf(stderr, "lttctl_client: trace: %s->%s->%s is done\n",

                     provider, target, trace);

 

         clear_trap(&trap);

@@ -300,7 +300,7 @@

     int i;

 

     if (error) {

-        printf("Reply error %d: %s\n", error, errno_to_str(error));

+        fprintf(stderr, "Reply error %d: %s\n", error, errno_to_str(error));

         if (last_provider && last_target && last_trace)

             destroy_trace(last_provider, last_target, last_trace);

         cmd_done();

@@ -317,7 +317,7 @@

     /* We flush the stream to be able to connect to the client with pipes

      * and receive the message when it's displayed */

     fflush(0);

-    /* fprintf(stderr, "lttctlclient : Just received a reply!\n"); */

+    /* fprintf(stderr, "lttctl_client: Just received a reply!\n"); */

 

     cmd_done();

 }

@@ -440,7 +440,7 @@

     Channel * c = chan;

 

     if (c == NULL) {

-        printf("Error: Channel not connected, use 'connect' command\n");

+        fprintf(stderr, "Error: Channel not connected, use 'connect' command\n");

         goto flush_output;

     }

     ind = 0;

@@ -449,16 +449,16 @@

         args[ind] = strtok(NULL, " \t");

     }

     if (args[0] == NULL || args[1] == NULL) {

-        printf("Error: Expected at least service and command name arguments\n");

+        fprintf(stderr, "Error: Expected at least service and command name arguments\n");

         goto flush_output;

     }

     if (strcmp(WRITE_TRACE_NETWORK, args[1])) {

-        printf("Error: lttctl_client can only handle the " WRITE_TRACE_NETWORK

+        fprintf(stderr, "Error: lttctl_client can only handle the " WRITE_TRACE_NETWORK

                 "command, use the tcf command instead\n");

         goto flush_output;

     }

     if (ind < 10) {

-        printf("Error: this command needs 10 arguments\n");

+        fprintf(stderr, "Error: this command needs 10 arguments\n");

         goto flush_output;

     }

     *(args[3] - 2) = '\0';

@@ -466,7 +466,7 @@

     *(args[5] - 2) = '\0';

     *(args[6] - 2) = '\0';

     if (create_base_trace(args[2]+1, args[3]+1, args[4]+1, args[5]+1)) {

-        printf("Error: Can't create the base trace structure\n");

+        fprintf(stderr, "Error: Can't create the base trace structure\n");

         goto flush_output;

     }

     *(args[3] - 2) = '"';

@@ -482,7 +482,7 @@

     write_stream(&c->out, MARKER_EOM);

     flush_stream(&c->out);

 

-    /* fprintf(stderr, "lttctlclient : Just sent a cmd!\n"); */

+    /* fprintf(stderr, "lttctl_client: Just sent a cmd!\n"); */

 

     return 1;

 

@@ -501,50 +501,50 @@

     int (*add_disconnect_callback)(void (*)(Channel *));

 

     if (!proto) {

-        fprintf(stderr, "Error %s : can't load without a valid protocol\n",

+        fprintf(stderr, "Error %s: can't load without a valid protocol\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

 

     cmd_done = plugin_get_function("Cmdline_cmd_done");

     if (!cmd_done) {

-        fprintf(stderr, "Error %s : the Cmdline service isn't loaded\n",

+        fprintf(stderr, "Error %s: the Cmdline service isn't loaded\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

     add_cmdline_cmd = plugin_get_function("Cmdline_add_cmd");

     if (!add_cmdline_cmd) {

-        fprintf(stderr, "Error %s : the Cmdline service isn't loaded\n",

+        fprintf(stderr, "Error %s: the Cmdline service isn't loaded\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

     add_connect_callback = plugin_get_function("Cmdline_add_connect_callback");

     if (!add_connect_callback) {

-        fprintf(stderr, "Error %s : the Cmdline service isn't loaded\n",

+        fprintf(stderr, "Error %s: the Cmdline service isn't loaded\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

     add_disconnect_callback = plugin_get_function(

             "Cmdline_add_disconnect_callback");

     if (!add_disconnect_callback) {

-        fprintf(stderr, "Error %s : the Cmdline service isn't loaded\n",

+        fprintf(stderr, "Error %s: the Cmdline service isn't loaded\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

     if (add_cmdline_cmd("lttctl_client", "call lttctl specific command",

             cmd_lttctl_client)) {

-        fprintf(stderr, "Error %s : can't add the lttctl_client command\n",

+        fprintf(stderr, "Error %s: can't add the lttctl_client command\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

     if (add_connect_callback(on_connect_callback)) {

-        fprintf(stderr, "Error %s : can't add the lttctl_client on connect"

+        fprintf(stderr, "Error %s: can't add the lttctl_client on connect"

                 " callback\n",

                 LTT_CONTROL_CLIENT);

         return;

     }

     if (add_disconnect_callback(on_disconnect_callback)) {

-        fprintf(stderr, "Error %s : can't add the lttctl_client on disconnect"

+        fprintf(stderr, "Error %s: can't add the lttctl_client on disconnect"

                 " callback\n",

                 LTT_CONTROL_CLIENT);

         return;

________________________________

 

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Système de systèmes (SdS) / System of Systems (SoS)
Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538

NAC: 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ> 
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/ <http://www.valcartier.drdc-rddc.gc.ca/> >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.casi.polymtl.ca/pipermail/lttng-dev/attachments/20110721/712cf3b0/attachment-0003.htm>


More information about the lttng-dev mailing list