]> sourceware.org Git - systemtap.git/commitdiff
Fix problems with varargs macros in dyninst/io.c.
authorDavid Smith <dsmith@redhat.com>
Tue, 7 Aug 2012 22:32:01 +0000 (17:32 -0500)
committerDavid Smith <dsmith@redhat.com>
Tue, 7 Aug 2012 22:32:01 +0000 (17:32 -0500)
* runtime/dyninst/io.c: Convert _stp_warn(), _stp_error(),
  _stp_softerror(), and _stp_dbug() from varargs macros into varargs
  functions so that calling _stp_warn() (for example) with just a format
  argument works correctly.

runtime/dyninst/io.c

index fb76bc525aa7c2b2145e80947fc31719bc6376d5..e464e642144833bd3e286bf0248509ad1c8ca4e8 100644 (file)
 
 // XXX for now, all IO is going in-process to stdout/err
 
-#define _stp_warn(fmt, ...) fprintf(stderr, WARN_STRING fmt "\n", ##__VA_ARGS__)
-#define _stp_error(fmt, ...) fprintf(stderr, ERR_STRING fmt "\n", ##__VA_ARGS__)
-#define _stp_softerror(fmt, ...) fprintf(stderr, ERR_STRING fmt "\n", ##__VA_ARGS__)
-#define _stp_dbug(func, line, fmt, ...) \
-       fprintf(stderr, "%s:%d: " fmt "\n", (func), (line), ##__VA_ARGS__)
+/** Prints warning.
+ * This function sends a warning message immediately to staprun. It
+ * will also be sent over the bulk transport (relayfs) if it is
+ * being used. If the last character is not a newline, then one 
+ * is added. 
+ * @param fmt A variable number of args.
+ */
+static void _stp_warn (const char *fmt, ...)
+{
+       va_list args;
+       va_start(args, fmt);
+       fprintf(stderr, WARN_STRING);
+       vfprintf(stderr, fmt, args);
+       fprintf(stderr, "\n");
+       va_end(args);
+}
+
+
+/** Prints error message and exits.
+ * This function sends an error message immediately to staprun. It
+ * will also be sent over the bulk transport (relayfs) if it is
+ * being used. If the last character is not a newline, then one 
+ * is added. 
+ *
+ * After the error message is displayed, the module will be unloaded.
+ * @param fmt A variable number of args.
+ * @sa _stp_exit().
+ */
+static void _stp_error (const char *fmt, ...)
+{
+       va_list args;
+       va_start(args, fmt);
+       fprintf(stderr, ERR_STRING);
+       vfprintf(stderr, fmt, args);
+       fprintf(stderr, "\n");
+       va_end(args);
+// FIXME: need to exit here...
+//     _stp_exit();
+}
+
+
+/** Prints error message.
+ * This function sends an error message immediately to staprun. It
+ * will also be sent over the bulk transport (relayfs) if it is
+ * being used. If the last character is not a newline, then one 
+ * is added. 
+ *
+ * @param fmt A variable number of args.
+ * @sa _stp_error
+ */
+static void _stp_softerror (const char *fmt, ...)
+{
+       va_list args;
+       va_start(args, fmt);
+       fprintf(stderr, ERR_STRING);
+       vfprintf(stderr, fmt, args);
+       fprintf(stderr, "\n");
+       va_end(args);
+}
+
+
+static void _stp_dbug (const char *func, int line, const char *fmt, ...)
+{
+       va_list args;
+       va_start(args, fmt);
+       fprintf(stderr, "%s:%d: ", func, line);
+       vfprintf(stderr, fmt, args);
+       fprintf(stderr, "\n");
+       va_end(args);
+}
 
 #define _stp_exit() do { } while (0) // no transport, no action yet
 
This page took 0.027335 seconds and 5 git commands to generate.