]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Make butc logging use va_args
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Mon, 28 Sep 2009 08:43:24 +0000 (10:43 +0200)
committerDerrick Brashear <shadow|account-1000005@unknown>
Mon, 28 Sep 2009 08:59:25 +0000 (01:59 -0700)
Change the logging functions in butc so that they use va_args. This
means that we can prototype the logging functions, and kill a bunch
more compiler warnings.

Reviewed-on: http://gerrit.openafs.org/509
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/butc/error_macros.h
src/butc/lwps.c

index 26e8d2bf54060f1daf2916f27cf8ce20c89d84b3..5f6c760cafdbd144f9ba5f1f27d53e8ca89f6349 100644 (file)
             goto abort_exit;                                    \
         }
 
-/*need conversion to varargs*//*extern void ELog(afs_int32 task, char *str, char *a, char *b, char *c, char *d, char *e, char *f, char *g, char *h, char *i, char *j);
-extern void ErrorLog(int debug, afs_int32 task, afs_int32 error1, afs_int32 error2, char *str, char *a, char *b, char *c, char *d, char *e, char *f, char *g, char *h, char *i, char *j);
-extern void TLog(afs_int32 task, char *str, char *a, char *b, char *c, char *d, char *e, char *f, char *g, char *h, char *i, char *j);
-extern void TapeLog(int debug, afs_int32 task, afs_int32 error1, afs_int32 error2, char *str, char *a, char *b, char *c, char *d, char *e, char *f, char *g, char *h, char *i, char *j);*/
+extern void ErrorLog(int debug, afs_int32 task, afs_int32 error1,
+                    afs_int32 error2, char *fmt, ...);
+extern void TapeLog(int debug, afs_int32 task, afs_int32 error1,
+                   afs_int32 error2, char *fmt, ...);
+extern void TLog(afs_int32 task, char *fmt, ...);
+
 
 extern void FreeNode(afs_int32 taskID);
 extern void CreateNode(struct dumpNode **newNode);
index c4fded6cb967b0398cb576ceef0a6dcd4d37d4af..3639f74d7ef12aff46fc2701cc99954250f80ece 100644 (file)
@@ -138,14 +138,11 @@ static struct TapeBlock tapeBlock;
 char tapeVolumeHT[sizeof(struct volumeHeader) + 2 * sizeof(char)];
 
 void
-PrintLog(log, error1, error2, str, a, b, c, d, e, f, g, h, i, j)
-     FILE *log;
-     afs_int32 error1, error2;
-     char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+PrintLogStr(FILE *log, afs_int32 error1, afs_int32 error2, char *str)
 {
     char *err1, *err2;
 
-    fprintf(log, str, a, b, c, d, e, f, g, h, i, j);
+    fprintf(log, str);
     if (error1) {
        err2 = "vols";
        switch (error1) {
@@ -199,10 +196,8 @@ PrintLog(log, error1, error2, str, a, b, c, d, e, f, g, h, i, j)
 }
 
 void
-TapeLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j)
-     int debug;
-     afs_int32 task, error1, error2;
-     char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+TapeLogStr(int debug, afs_int32 task, afs_int32 error1, afs_int32 error2,
+          char *str)
 {
     time_t now;
     char tbuffer[32], *timestr;
@@ -214,35 +209,51 @@ TapeLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j)
     fprintf(logIO, "%s: ", timestr);
     if (task)
        fprintf(logIO, "Task %u: ", task);
-    PrintLog(logIO, error1, error2, str, a, b, c, d, e, f, g, h, i, j);
+    PrintLogStr(logIO, error1, error2, str);
 
     if (lastPass && lastLogIO) {
        fprintf(lastLogIO, "%s: ", timestr);
        if (task)
            fprintf(lastLogIO, "Task %u: ", task);
-       PrintLog(lastLogIO, error1, error2, str, a, b, c, d, e, f, g, h, i,
-                j);
+       PrintLogStr(lastLogIO, error1, error2, str);
     }
 
     /* Now print to the screen if debug level requires */
     if (debug <= debugLevel)
-       PrintLog(stdout, error1, error2, str, a, b, c, d, e, f, g, h, i, j);
+       PrintLogStr(stdout, error1, error2, str);
 }
 
 void
-TLog(task, str, a, b, c, d, e, f, g, h, i, j)
-     afs_int32 task;
-     char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+TapeLog(int debug, afs_int32 task, afs_int32 error1, afs_int32 error2,
+       char *fmt, ...)
 {
+    char tmp[1024];
+    va_list ap;
+
+    va_start(ap, fmt);
+    afs_vsnprintf(tmp, sizeof(tmp), fmt, ap);
+    va_end(ap);
+
+    TapeLogStr(debug, task, error1, error2, tmp);
+}
+
+void
+TLog(afs_int32 task, char *fmt, ...)
+{
+    char tmp[1024];
+    va_list ap;
+
+    va_start(ap, fmt);
+    afs_vsnprintf(tmp, sizeof(tmp), fmt, ap);
+    va_end(ap);
+
     /* Sends message to TapeLog and stdout */
-    TapeLog(0, task, 0, 0, str, a, b, c, d, e, f, g, h, i, j);
+    TapeLogStr(0, task, 0, 0, tmp);
 }
 
 void
-ErrorLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j)
-     int debug;
-     afs_int32 task, error1, error2;
-     char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+ErrorLogStr(int debug, afs_int32 task, afs_int32 error1, afs_int32 error2,
+           char *errStr)
 {
     time_t now;
     char tbuffer[32], *timestr;
@@ -255,18 +266,38 @@ ErrorLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j)
     /* Print the time and task number */
     if (task)
        fprintf(ErrorlogIO, "Task %u: ", task);
-    PrintLog(ErrorlogIO, error1, error2, str, a, b, c, d, e, f, g, h, i, j);
 
-    TapeLog(debug, task, error1, error2, str, a, b, c, d, e, f, g, h, i, j);
+    PrintLogStr(ErrorlogIO, error1, error2, errStr);
+    TapeLogStr(debug, task, error1, error2, errStr);
 }
 
 void
-ELog(task, str, a, b, c, d, e, f, g, h, i, j)
-     afs_int32 task;
-     char *str, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+ErrorLog(int debug, afs_int32 task, afs_int32 error1, afs_int32 error2,
+        char *fmt, ...)
 {
+    char tmp[1024];
+    va_list ap;
+
+    va_start(ap, fmt);
+    afs_vsnprintf(tmp, sizeof(tmp), fmt, ap);
+    va_end(ap);
+
+    ErrorLogStr(debug, task, error1, error2, tmp);
+
+}
+
+void
+ELog(afs_int32 task, char *fmt, ...)
+{
+    char tmp[1024];
+    va_list ap;
+
+    va_start(ap, fmt);
+    afs_vsnprintf(tmp, sizeof(tmp), fmt, ap);
+    va_end(ap);
+
     /* Sends message to ErrorLog, TapeLog and stdout */
-    ErrorLog(0, task, 0, 0, str, a, b, c, d, e, f, g, h, i, j);
+    ErrorLog(0, task, 0, 0, tmp);
 }
 
 /* first proc called by anybody who intends to use the device */