logging-cleanup-20030602
authorR. Lindsay Todd <toddr@rpi.edu>
Mon, 2 Jun 2003 15:37:48 +0000 (15:37 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 2 Jun 2003 15:37:48 +0000 (15:37 +0000)
FIXES 1493

logging function cleanup and protoizing

17 files changed:
src/util/afsutil.h
src/util/serverLog.c
src/vol/clone.c
src/vol/common.c
src/vol/fssync.c
src/vol/namei_ops.c
src/vol/nuke.c
src/vol/partition.c
src/vol/vnode.c
src/vol/vol-salvage.c
src/vol/volume.c
src/vol/vutil.c
src/volser/common.c
src/volser/dumpstuff.c
src/volser/volmain.c
src/volser/volprocs.c
src/volser/voltrans.c

index 2438ea6..6c3cdd7 100644 (file)
@@ -30,8 +30,10 @@ extern int serverLogSyslog;
 extern int serverLogSyslogFacility;
 extern char *serverLogSyslogTag;
 #endif
-extern void FSLog(const char *format, ...);
+extern void vFSLog(const char *format, va_list args);
+/*@printflike@*/ extern void FSLog(const char *format, ...);
 #define ViceLog(level, str)  if ((level) <= LogLevel) (FSLog str)
+#define vViceLog(level, str) if ((level) <= LogLevel) (vFSLog str)
 
 extern int OpenLog(const char *filename);
 extern int ReOpenLog(const char *fileName);
index 5f9cc8c..3c895dc 100644 (file)
@@ -91,11 +91,8 @@ void WriteLogBuffer(char *buf, afs_uint32 len)
     UNLOCK_SERVERLOG();
 }
 
-/* VARARGS1 */
-void FSLog (const char *format, ...)
+void vFSLog (const char *format, va_list args)
 {
-    va_list args;
-
     time_t currenttime;
     char *timeStamp;
     char tbuffer[1024];
@@ -114,9 +111,7 @@ void FSLog (const char *format, ...)
        info += strlen(info);
     }
 
-    va_start(args, format);
     (void) vsprintf(info, format, args);
-    va_end(args);
 
     len = strlen(tbuffer);
     LOCK_SERVERLOG();
@@ -135,7 +130,18 @@ void FSLog (const char *format, ...)
         fflush(stderr);     /* in case they're sharing the same FD */
     }
 #endif
-}
+} /*vFSLog*/
+
+/* VARARGS1 */
+/*@printflike@*/
+void FSLog(const char *format, ...)
+{
+    va_list args;
+
+    va_start(args, format);
+    vFSLog(format, args);
+    va_end(args);
+} /*FSLog*/
 
 static int DebugOn(int loglevel)
 {
index 6e9a385..48a1131 100644 (file)
@@ -59,6 +59,8 @@ RCSID("$Header$");
 #include "partition.h"
 #include "viceinode.h"
 
+/*@printfline@*/ extern void Log(const char *format, ...);
+
 int (*vol_PollProc)() =        0;  /* someone must init this */
 
 #define ERROR_EXIT(code) {error = code; goto error_exit;}
index ee5d09b..c377734 100644 (file)
@@ -25,30 +25,38 @@ RCSID("$Header$");
 
 int Statistics = 0;
 
-/* VARARGS */
-Log (a,b,c,d,e,f,g,h,i,j,k)
-    char *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
+/*@printflike@*/ void Log(const char *format, ...)
 {
-    int level;
+    int        level;
+    va_list args;
 
     if (Statistics)
        level = -1;
     else
        level = 0;
-    ViceLog(level,(a,b,c,d,e,f,g,h,i,j,k));
+
+    va_start(args, format);
+    vViceLog(level, (format, args));
+    va_end(args);
 }
 
-Abort(s,a,b,c,d,e,f,g,h,i,j) 
-    char *s, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+/*@printflike@*/ void Abort(const char *format, ...)
 {
+    va_list args;
+
     ViceLog(0, ("Program aborted: "));
-    ViceLog(0, (s,a,b,c,d,e,f,g,h,i,j));
+    va_start(args, format);
+    vViceLog(0, (format, args));
+    va_end(args);
     abort();
 }
 
-Quit(s,a,b,c,d,e,f,g,h,i,j) 
-    char *s, *a, *b, *c, *d, *e, *f, *g, *h, *i, *j;
+/*@printflike@*/ void Quit(const char *format, ...)
 {
-    ViceLog(0, (s,a,b,c,d,e,f,g,h,i,j));
+    va_list args;
+
+    va_start(args, format);
+    vViceLog(0, (format, args));
+    va_end(args);
     exit(1);
 }
index ef447c9..2720a85 100644 (file)
@@ -82,6 +82,8 @@ RCSID("$Header$");
 #include "volume.h"
 #include "partition.h"
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 #ifdef osi_Assert
 #undef osi_Assert
 #endif
index f04c11d..1e0d513 100644 (file)
@@ -44,6 +44,8 @@ RCSID("$Header$");
 #include "partition.h"
 #include <afs/errors.h>
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 extern char *volutil_PartitionName_r(int volid, char *buf, int buflen);
 
 int namei_iread(IHandle_t *h, int offset, char *buf, int size)
index f672c07..cf6fb87 100644 (file)
@@ -42,6 +42,8 @@ RCSID("$Header$");
 #include "salvage.h"
 #include "fssync.h"
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 
 struct Lock localLock;
 char *vol_DevName();
index 60a07c2..72a2ff9 100644 (file)
@@ -146,6 +146,8 @@ RCSID("$Header$");
 #include <jfs/filsys.h>
 #endif
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 int aixlow_water = 8;  /* default 8% */
 struct DiskPartition *DiskPartitionList;
 
index 7fe9b81..04cd67b 100644 (file)
@@ -63,6 +63,8 @@ RCSID("$Header$");
 #endif /* AFS_NT40_ENV */
 #include <sys/stat.h>
 
+extern void Abort(const char *format, ...);
+
 
 struct VnodeClassInfo VnodeClassInfo[nVNODECLASSES];
 
index 481d6f2..52262a5 100644 (file)
@@ -391,7 +391,9 @@ typedef struct {
 
 
 /* Forward declarations */
-void Log(), Abort(), Exit();
+/*@printflike@*/ void Log(const char *format, ...);
+/*@printflike@*/ void Abort(const char *format, ...);
+void Exit(int code);
 int Fork(void);
 int Wait(char *prog);
 char * ToString(char *s);
@@ -3659,39 +3661,49 @@ void showlog(void)
     }
 }
 
-void Log(a,b,c,d,e,f,g,h,i,j,k)
-char *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
+void Log(const char *format, ...)
 {
     struct timeval now;
+    va_list args;
 
+    va_start(args, format);
 #ifndef AFS_NT40_ENV
-       if ( useSyslog )
-       {
-               syslog(LOG_INFO, a,b,c,d,e,f,g,h,i,j,k);
-       } else 
+    if ( useSyslog )
+    {
+       char tmp[1024];
+       (void) vsnprintf(tmp, sizeof tmp, format, args);
+       syslog(LOG_INFO, "%s", tmp);
+    } else 
 #endif
-       {
-           gettimeofday(&now, 0);
-           fprintf(logFile, "%s ", TimeStamp(now.tv_sec, 1));
-           fprintf(logFile, a,b,c,d,e,f,g,h,i,j,k);
-           fflush(logFile);
-       }
+    {
+       gettimeofday(&now, 0);
+       fprintf(logFile, "%s ", TimeStamp(now.tv_sec, 1));
+       vfprintf(logFile, format, args);
+       fflush(logFile);
+    }
+    va_end(args);
 }
 
-void Abort(a,b,c,d,e,f,g,h,i,j,k)
-char *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
+void Abort(const char *format, ...)
 {
+    va_list args;
+
+    va_start(args, format);
 #ifndef AFS_NT40_ENV
-       if ( useSyslog )
-       {
-               syslog(LOG_INFO, a,b,c,d,e,f,g,h,i,j,k);
-       } else 
+    if ( useSyslog )
+    {
+       char tmp[1024];
+       (void) vsnprintf(tmp, sizeof tmp, format, args);
+       syslog(LOG_INFO, "%s", tmp);
+    } else 
 #endif
-       {
-           fprintf(logFile, a,b,c,d,e,f,g,h,i,j,k);
-           fflush(logFile);
-           if (ShowLog) showlog();
-       }
+    {
+       vfprintf(logFile, format, args);
+       fflush(logFile);
+       if (ShowLog) showlog();
+    }
+    va_end(args);
+
     if (debug)
        abort();
     Exit(1);
index d7091f1..a397359 100644 (file)
@@ -145,6 +145,8 @@ pthread_cond_t vol_sleep_cond;
 extern void *calloc(), *realloc();
 #endif
 
+/*@printflike@*/ extern void Log(const char* format, ...);
+
 /* Forward declarations */
 static Volume *attach2();
 static void FreeVolume();
index 4e63c81..46cb252 100644 (file)
@@ -64,6 +64,8 @@ RCSID("$Header$");
 #include <strings.h>
 #endif
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 void AssignVolumeName();
 void AssignVolumeName_r();
 void ClearVolumeStats();
index a3247cc..152c113 100644 (file)
@@ -16,23 +16,28 @@ RCSID("$Header$");
 #include <afs/afsutil.h>
 #include <afs/com_err.h>
 
-Log(a,b,c,d,e,f)
-char *a, *b, *c, *d, *e, *f; 
+/*@printflike@*/ void Log(const char *format, ...)
 {
-       ViceLog(0, (a, b,c, d, e, f)); 
+    va_list args;
+
+    va_start(args, format);
+    vViceLog(0, (format, args));
+    va_end(args);
 }
 
-LogError(errcode)
-afs_int32 errcode;
+void LogError(afs_int32 errcode)
 {
     ViceLog(0, ("%s: %s\n", error_table_name(errcode),error_message(errcode)));
 }
 
-Abort(s,a,b,c,d,e,f,g,h,i,j) 
-char *s;
+/*@printflike@*/ void Abort(const char* format, ...)
 {
+    va_list args;
+
     ViceLog(0, ("Program aborted: "));
-    ViceLog(0, (s,a,b,c,d,e,f,g,h,i,j));
+    va_start(args, format);
+    vViceLog(0, (format, args));
+    va_end(args);
     abort();
 }
 
index f61c653..ad98ad7 100644 (file)
@@ -51,6 +51,8 @@ RCSID("$Header$");
 #include "volser.h"
 #include "volint.h"
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 extern int DoLogging;
 
 /* This iod stuff is a silly little package to emulate the old qi_in stuff, which
index eb197e2..d5552d8 100644 (file)
@@ -60,6 +60,9 @@ RCSID("$Header$");
 #include <afs/audit.h>
 #include <afs/afsutil.h>
 
+/*@printflike@*/ extern void Log(const char* format, ...);
+/*@printflike@*/ extern void Abort(const char *format, ...);
+
 #define VolserVersion "2.0"
 #define N_SECURITY_OBJECTS 3
 
@@ -79,7 +82,6 @@ extern int (*VolWriteProc)();
 extern int (*VolFlushProc)();
 extern void AFSVolExecuteRequest();
 extern void RXSTATS_ExecuteRequest();
-extern Log();
 struct afsconf_dir *tdir;
 static afs_int32 runningCalls=0;
 int DoLogging = 0;
index f210bfe..20658a6 100644 (file)
@@ -71,6 +71,8 @@ extern struct volser_trans *FindTrans(), *NewTrans(),*TransList();
 extern struct afsconf_dir *tdir;
 extern char *volutil_PartitionName();
 
+extern void LogError(afs_int32 errcode);
+
 /* Forward declarations */
 static int GetPartName(afs_int32 partid, char *pname);
 
index 1efe2cb..7b24ed5 100644 (file)
@@ -36,6 +36,8 @@ RCSID("$Header$");
 #include <rx/rx.h>
 #include "volser.h"
 
+/*@printflike@*/ extern void Log(const char *format, ...);
+
 static struct volser_trans *allTrans=0;
 static afs_int32 transCounter = 1;