]> sourceware.org Git - systemtap.git/commitdiff
make STP_OOB_DATA treatment more stringent
authorJonathan Lebon <jlebon@redhat.com>
Thu, 4 Jul 2013 20:55:28 +0000 (16:55 -0400)
committerJonathan Lebon <jlebon@redhat.com>
Fri, 5 Jul 2013 13:43:51 +0000 (09:43 -0400)
Since all STP_OOB_DATA originally comes from _stp_vlog() in
runtime/linux/io.c, we can be sure that all warnings will be prefixed
by "WARNING: " and all errors by "ERROR: ", as defined by WARN_STRING
ERR_STRING in io.c.

Therefore, we can be more stringent in control.c and mainloop.c in the
way we identify warnings and errors. Additionally, warnings can instead
use the warn() macro and errors the err() macro so that they benefit
from coloring.

The main effect of this patch is that all calls to _stp_warn() and
_stp_error() will be colored upon reception by stapio.

runtime/transport/control.c
staprun/mainloop.c

index cbc8e6d559ae9f7fe6b8a303e3988dec6e666830..0ddfbb3cd6312fbab641c777422f708a398f7962 100644 (file)
@@ -337,14 +337,14 @@ static struct _stp_buffer *_stp_ctl_get_buffer(int type, void *data,
                        /* Note that "WARNING:" should not be
                         * translated, since it is part of the module
                         * cmd protocol. */
-                       if (data && len >= 7
-                           && strncmp(data, "WARNING:", 7) == 0)
+                       if (data && len >= 9
+                           && strncmp(data, "WARNING: ", 9) == 0)
                                bptr = _stp_ctl_oob_warn;
                        /* Note that "ERROR:" should not be
                         * translated, since it is part of the module
                         * cmd protocol. */
-                       else if (data && len >= 5
-                                && strncmp(data, "ERROR:", 5) == 0)
+                       else if (data && len >= 7
+                                && strncmp(data, "ERROR: ", 7) == 0)
                                bptr = _stp_ctl_oob_err;
                        else
                                printk(KERN_WARNING "_stp_ctl_get_buffer unexpected STP_OOB_DATA\n");
index 9035c8cd61f4cc0ef46c0056668b7610357e9780..d5c61b18a3932cb511ad6c87a89eee2f826d3911 100644 (file)
@@ -658,10 +658,11 @@ int stp_main_loop(void)
     case STP_OOB_DATA:
       /* Note that "WARNING:" should not be translated, since it is
        * part of the module cmd protocol. */
-      if (strncmp(recvbuf.payload.data, "WARNING:", 7) == 0) {
+      if (strncmp(recvbuf.payload.data, "WARNING: ", 9) == 0) {
               if (suppress_warnings) break;
               if (verbose) { /* don't eliminate duplicates */
-                      eprintf("%.*s", (int) nb, recvbuf.payload.data);
+                      /* trim "WARNING: " */
+                      warn("%.*s", (int) nb-9, recvbuf.payload.data+9);
                       break;
               } else { /* eliminate duplicates */
                       static void *seen = 0;
@@ -671,13 +672,15 @@ int stp_main_loop(void)
 
                       if (! dupstr) {
                               /* OOM, should not happen. */
-                              eprintf("%.*s", (int) nb, recvbuf.payload.data);
+                              /* trim "WARNING: " */
+                              warn("%.*s", (int) nb-9, recvbuf.payload.data+9);
                               break;
                       }
 
                       retval = tfind (dupstr, & seen, (int (*)(const void*, const void*))strcmp);
                       if (! retval) { /* new message */
-                              eprintf("%s", dupstr);
+                              /* trim "WARNING: " */
+                              warn("%.*s", strlen(dupstr)-9, dupstr+9);
 
                               /* We set a maximum for stored warning messages,
                                  to prevent a misbehaving script/environment
@@ -711,8 +714,9 @@ int stp_main_loop(void)
               } /* duplicate elimination */
       /* Note that "ERROR:" should not be translated, since it is
        * part of the module cmd protocol. */
-      } else if (strncmp(recvbuf.payload.data, "ERROR:", 5) == 0) {
-              eprintf("%.*s", (int) nb, recvbuf.payload.data);
+      } else if (strncmp(recvbuf.payload.data, "ERROR: ", 7) == 0) {
+              /* trim "ERROR: " */
+              err("%.*s", (int) nb-7, recvbuf.payload.data+7);
               error_detected = 1;
       } else { /* neither warning nor error */
               eprintf("%.*s", (int) nb, recvbuf.payload.data);
This page took 0.031652 seconds and 5 git commands to generate.