]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
vol: Fix logging functions
authorSimon Wilkinson <sxw@inf.ed.ac.uk>
Fri, 16 Jul 2010 22:20:27 +0000 (23:20 +0100)
committerDerrick Brashear <shadow@dementia.org>
Sun, 18 Jul 2010 15:12:18 +0000 (08:12 -0700)
Fix the Log, Abort and Quit functions used by the vol package so
that they are all defined in a common header file, rather than
prototyped in each file which uses them.

Use the appropriate macros to flag those functions which never
return, and mark them all as taking printf style input.

Fix all of the callers which had mismatched format strings and
arguments.

Change-Id: I78194f623360e13f055f8f37b3558c08a70acd1f
Reviewed-on: http://gerrit.openafs.org/2444
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
18 files changed:
src/vol/clone.c
src/vol/common.c
src/vol/common.h [new file with mode: 0644]
src/vol/daemon_com.c
src/vol/fssync-client.c
src/vol/fssync-server.c
src/vol/namei_ops.c
src/vol/nuke.c
src/vol/partition.c
src/vol/purge.c
src/vol/salvaged.c
src/vol/salvager.c
src/vol/salvsync-client.c
src/vol/salvsync-server.c
src/vol/vnode.c
src/vol/vol-salvage.c
src/vol/volume.c
src/vol/vutil.c

index 9e68ab57a5e9d9842e463de35104a8cff318ee8d..13cef1bb6256ddb7a90a1fc1bd77c445152169d9 100644 (file)
@@ -53,8 +53,7 @@
 #include "partition.h"
 #include "viceinode.h"
 #include "vol_prototypes.h"
-
-/*@printflike@*/ extern void Log(const char *format, ...);
+#include "common.h"
 
 int (*vol_PollProc) (void) = 0;        /* someone must init this */
 
@@ -260,7 +259,7 @@ DoCloneIndex(Volume * rwvp, Volume * clvp, VnodeClass class, int reclone)
            } else if (rwinode) {
                if (IH_INC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) ==
                    -1) {
-                   Log("IH_INC failed: %x, %s, %u errno %d\n",
+                   Log("IH_INC failed: %"AFS_PTR_FMT", %s, %u errno %d\n",
                        V_linkHandle(rwvp), PrintInode(NULL, rwinode),
                        V_parentId(rwvp), errno);
                    VForceOffline(rwvp);
@@ -313,7 +312,7 @@ DoCloneIndex(Volume * rwvp, Volume * clvp, VnodeClass class, int reclone)
            if (inodeinced) {
                if (IH_DEC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) ==
                    -1) {
-                   Log("IH_DEC failed: %x, %s, %u errno %d\n",
+                   Log("IH_DEC failed: %"AFS_PTR_FMT", %s, %u errno %d\n",
                        V_linkHandle(rwvp), PrintInode(NULL, rwinode),
                        V_parentId(rwvp), errno);
                    VForceOffline(rwvp);
index 753daef0ba316cf7b46705e289a32917f774f7a0..6d6625f6b6dc8059105ef0e29f6a7c605bc05b3c 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <afs/afsutil.h>
 
+#include "common.h"
+
 int Statistics = 0;
 
 /*@printflike@*/ void
diff --git a/src/vol/common.h b/src/vol/common.h
new file mode 100644 (file)
index 0000000..b2bc758
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef AFS_SRC_VOL_COMMON_H
+#define AFS_SRC_VOL_COMMON_H
+
+/* common.c */
+extern void Log(const char *format, ...)
+       AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
+extern void Abort(const char *format, ...)
+       AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2)
+       AFS_NORETURN;
+extern void Quit(const char *format, ...)
+       AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2)
+       AFS_NORETURN;
+
+#endif
index aaf67801bbddf31540f32bc9976e8eb193b73c7e..3f582140f7449520a6ea7ac61069e3a528d6a9cf 100644 (file)
@@ -53,6 +53,7 @@
 #include "vnode.h"
 #include "volume.h"
 #include "partition.h"
+#include "common.h"
 #include <rx/rx_queue.h>
 
 #ifdef USE_UNIX_SOCKETS
@@ -60,8 +61,6 @@
 #include <sys/un.h>
 #endif
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 int (*V_BreakVolumeCallbacks) (VolumeId);
 
 #define MAXHANDLERS    4       /* Up to 4 clients; must be at least 2, so that
index 4fa64486c8608bd54674de2f7a6b302ebb066547..1725fa40ddc58406913299e50bc651de584d46b7 100644 (file)
 #include "vnode.h"
 #include "volume.h"
 #include "partition.h"
+#include "common.h"
 
 #ifdef FSSYNC_BUILD_CLIENT
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 extern int LogLevel;
 
 static SYNC_client_state fssync_state = 
index f79f1e39a44a785f87b2da6a4cbfb42680f272dd..c54ad3712e0dbeb3c5d4917b7760f649b56f3ccc 100644 (file)
@@ -87,6 +87,7 @@
 #include "volume_inline.h"
 #include "partition.h"
 #include "vg_cache.h"
+#include "common.h"
 
 #ifdef HAVE_POLL
 #include <sys/poll.h>
 
 #ifdef FSSYNC_BUILD_SERVER
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 int (*V_BreakVolumeCallbacks) (VolumeId volume);
 
 #define MAXHANDLERS    4       /* Up to 4 clients; must be at least 2, so that
index 26a0a753a5ce3e10fd70e6de4ef8fb6b66b37dc4..dc4cd8f20ef79160df2309c20261d7f00d4414dc 100644 (file)
@@ -41,6 +41,7 @@
 #include "partition.h"
 #include "fssync.h"
 #include "volume_inline.h"
+#include "common.h"
 #include <afs/errors.h>
 
 /*@+fcnmacros +macrofcndecl@*/
@@ -65,8 +66,6 @@ extern off_t afs_lseek(int FD, off_t O, int F);
 #endif /* !O_LARGEFILE */
 /*@=fcnmacros =macrofcndecl@*/
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 #ifndef LOCK_SH
 #define   LOCK_SH   1    /* shared lock */
 #define   LOCK_EX   2    /* exclusive lock */
@@ -1261,8 +1260,9 @@ ListViceInodes(char *devname, char *mountedOn, FILE *inodeFile,
        return -2;
     }
     if (status.st_size != ninodes * sizeof(struct ViceInodeInfo)) {
-       Log("Wrong size (%d instead of %d) in inode file for %s\n",
-           status.st_size, ninodes * sizeof(struct ViceInodeInfo),
+       Log("Wrong size (%d instead of %lu) in inode file for %s\n",
+           (int) status.st_size,
+           (long unsigned int) ninodes * sizeof(struct ViceInodeInfo),
            mountedOn);
        return -2;
     }
@@ -1557,7 +1557,8 @@ convertVolumeInfo(int fdr, int fdw, afs_uint32 vid)
 
     if (read(fdr, &vd, sizeof(struct VolumeDiskData)) !=
        sizeof(struct VolumeDiskData)) {
-       Log("1 convertVolumeInfo: read failed for %lu with code %d\n", vid,
+       Log("1 convertVolumeInfo: read failed for %lu with code %d\n",
+           afs_printable_uint32_lu(vid),
            errno);
        return -1;
     }
@@ -1575,7 +1576,8 @@ convertVolumeInfo(int fdr, int fdw, afs_uint32 vid)
     }
     if (write(fdw, &vd, sizeof(struct VolumeDiskData)) !=
        sizeof(struct VolumeDiskData)) {
-       Log("1 convertVolumeInfo: write failed for %lu with code %d\n", vid,
+       Log("1 convertVolumeInfo: write failed for %lu with code %d\n",
+           afs_printable_uint32_lu(vid),
            errno);
        return -1;
     }
@@ -1697,7 +1699,9 @@ namei_ConvertROtoRWvolume(char *pname, afs_uint32 volumeId)
                    continue;
                }
            }
-           Log("1 namei_ConvertROtoRWvolume: found special file %s/%s for volume %lu\n", dir_name, dp->d_name, info.u.param[0]);
+           Log("1 namei_ConvertROtoRWvolume: found special file %s/%s"
+               " for volume %lu\n", dir_name, dp->d_name,
+               afs_printable_uint32_lu(info.u.param[0]));
            closedir(dirp);
            code = VVOLEXISTS;
            goto done;
index b937f5456c263653d320689ff54f1665bc615c33..ae26a479243c2d2a68b4f79a56d397da451fab4e 100644 (file)
@@ -45,6 +45,7 @@
 #include "salvage.h"
 #include "daemon_com.h"
 #include "fssync.h"
+#include "common.h"
 
 #ifdef O_LARGEFILE
 #define afs_stat       stat64
@@ -52,9 +53,6 @@
 #define afs_stat       stat
 #endif /* !O_LARGEFILE */
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
-
 struct Lock localLock;
 
 #define MAXATONCE      100
index ca0aa3bc9a402ffea4f1541b492b6c55e709aeeb..f9297f9248f76b6e03d5404befbfa38b62f74d69 100644 (file)
 #include "lwp.h"
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
+#include "common.h"
 #ifdef AFS_NAMEI_ENV
 #ifdef AFS_NT40_ENV
 #include "ntops.h"
 
 #endif /* !O_LARGEFILE */
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 int aixlow_water = 8;          /* default 8% */
 struct DiskPartition64 *DiskPartitionList;
 
@@ -1093,12 +1092,14 @@ VPrintDiskStats_r(void)
     struct DiskPartition64 *dp;
     for (dp = DiskPartitionList; dp; dp = dp->next) {
        if (dp->free < 0) {
-           Log("Partition %s: %d available 1K blocks (minfree=%d), "
-               "overallocated by %d blocks\n", dp->name,
+           Log("Partition %s: %"AFS_INT64_FMT
+               " available 1K blocks (minfree=%"AFS_INT64_FMT"), "
+               "overallocated by %"AFS_INT64_FMT" blocks\n", dp->name,
                dp->totalUsable, dp->minFree, -dp->free);
        } else {
-           Log("Partition %s: %d available 1K blocks (minfree=%d), "
-               "%d free blocks\n", dp->name,
+           Log("Partition %s: %"AFS_INT64_FMT
+               " available 1K blocks (minfree=%"AFS_INT64_FMT"), "
+               "%"AFS_INT64_FMT" free blocks\n", dp->name,
                dp->totalUsable, dp->minFree, dp->free);
        }
     }
index 17029abc7c07a20c3abbb84b91e6a2a202745fea..d1f0fb6c8f8c312e3fe5c396ecf9018f7603416f 100644 (file)
@@ -48,6 +48,7 @@
 #include "partition.h"
 #include "daemon_com.h"
 #include "fssync.h"
+#include "common.h"
 
 /* forward declarations */
 static int ObliterateRegion(Volume * avp, VnodeClass aclass, StreamHandle_t * afile,
@@ -60,8 +61,6 @@ static void PurgeHeader(Volume * vp);
 static void PurgeIndex_r(Volume * vp, VnodeClass class);
 static void PurgeHeader_r(Volume * vp);
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 /* No lock needed. Only the volserver will call this, and only one transaction
  * can have a given volume (volid/partition pair) in use at a time 
  */
index f1dde1f943305c81b921fc0b93f35b24c6116562..6b6199d76221a7293c9146370b6ac2734fd1327b 100644 (file)
 #include "viceinode.h"
 #include "salvage.h"
 #include "vol-salvage.h"
+#include "common.h"
 #ifdef AFS_NT40_ENV
 #include <pthread.h>
 #endif
 #error "online salvager not supported on NT"
 #endif /* AFS_NT40_ENV */
 
-
-/* Forward declarations */
-/*@printflike@*/ void Log(const char *format, ...);
-
-
 /*@+fcnmacros +macrofcndecl@*/
 #ifdef O_LARGEFILE
 #define afs_fopen      fopen64
index 8d7ec45cba833e5d8a0a32fa4e0773f8b05727a2..c12f338c4b439ffac8a22e3f9273be0566b52bc9 100644 (file)
 #include "viceinode.h"
 #include "salvage.h"
 #include "vol-salvage.h"
+#include "common.h"
 #ifdef AFS_NT40_ENV
 #include <pthread.h>
 pthread_t main_thread;
 #endif
 
-
 static int get_salvage_lock = 0;
 
-
-/* Forward declarations */
-/*@printflike@*/ void Log(const char *format, ...);
-/*@printflike@*/ void Abort(const char *format, ...);
-
-
 static int
 handleit(struct cmd_syndesc *as, void *arock)
 {
index f2255dc0fe447b5cb3035e948e794ffa8f701959..e62e5f60283a7d411f962b5af8b9a90976093f22 100644 (file)
 #include "vnode.h"
 #include "volume.h"
 #include "partition.h"
+#include "common.h"
 #include <rx/rx_queue.h>
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 #ifdef AFS_DEMAND_ATTACH_FS
 /*
  * SALVSYNC is a feature specific to the demand attach fileserver
index f3cdc23f2b51a9b7353de24934edf55b7f336ba2..1a9ab88a3ae71da0158eb560ec1881cb68b3a0b8 100644 (file)
@@ -57,6 +57,7 @@
 #include "vnode.h"
 #include "volume.h"
 #include "partition.h"
+#include "common.h"
 #include <rx/rx_queue.h>
 #include <afs/procmgmt.h>
 
@@ -73,8 +74,6 @@
 #define WCOREDUMP(x)    ((x) & 0200)
 #endif
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 #define MAXHANDLERS    4       /* Up to 4 clients; must be at least 2, so that
                                 * move = dump+restore can run on single server */
 
index 3b1137747212691fb57a1b314d3e6919e7af98c7..3ae24e751ca63b9446e11e6cf712e572c3ab5e89 100644 (file)
@@ -45,6 +45,7 @@
 #include "vnode_inline.h"
 #include "partition.h"
 #include "salvsync.h"
+#include "common.h"
 #if defined(AFS_SGI_ENV)
 #include "sys/types.h"
 #include "fcntl.h"
 # include <stdint.h>
 #endif
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
-/*@printflike@*/ extern void Abort(const char *format, ...) AFS_NORETURN;
-
-
 struct VnodeClassInfo VnodeClassInfo[nVNODECLASSES];
 
 void VNLog(afs_int32 aop, afs_int32 anparms, ... );
@@ -1032,8 +1028,9 @@ VnStore(Error * ec, Volume * vp, Vnode * vnp,
        goto error_encountered;
     }
     if (FDH_SEEK(fdP, offset, SEEK_SET) < 0) {
-       Log("VnStore: can't seek on index file! fdp=0x%x offset=%d, errno=%d\n",
-           fdP, offset, errno);
+       Log("VnStore: can't seek on index file! fdp=%"AFS_PTR_FMT
+           " offset=%d, errno=%d\n",
+           fdP, (int) offset, errno);
        goto error_encountered;
     }
 
@@ -1356,7 +1353,7 @@ VPutVnode_r(Error * ec, register Vnode * vnp)
                                                changed_oldTime) << 1) | vnp->
              delete, 0, 0);
        if (thisProcess != vnp->writer)
-           Abort("VPutVnode: Vnode at 0x%x locked by another process!\n",
+           Abort("VPutVnode: Vnode at %"AFS_PTR_FMT" locked by another process!\n",
                  vnp);
 
 
@@ -1412,7 +1409,8 @@ VPutVnode_r(Error * ec, register Vnode * vnp)
     } else {                   /* Not write locked */
        if (vnp->changed_newTime || vnp->changed_oldTime || vnp->delete)
            Abort
-               ("VPutVnode: Change or delete flag for vnode 0x%x is set but vnode is not write locked!\n",
+               ("VPutVnode: Change or delete flag for vnode "
+                "%"AFS_PTR_FMT" is set but vnode is not write locked!\n",
                 vnp);
 #ifdef AFS_DEMAND_ATTACH_FS
        VnEndRead_r(vnp);
@@ -1499,8 +1497,8 @@ VVnodeWriteToRead_r(Error * ec, register Vnode * vnp)
     LWP_CurrentProcess(&thisProcess);
 #endif /* AFS_PTHREAD_ENV */
     if (thisProcess != vnp->writer)
-       Abort("VPutVnode: Vnode at 0x%x locked by another process!\n",
-             (intptr_t)vnp);
+       Abort("VPutVnode: Vnode at %"AFS_PTR_FMT
+             " locked by another process!\n", vnp);
 
     if (vnp->delete) {
        return 0;
index 1488bee11cb348cdf28f899dbb41b2e342717783..408bc5ead04363b5c9160528a725420d6a6d1d99 100644 (file)
@@ -189,6 +189,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #include "salvage.h"
 #include "volinodes.h"         /* header magic number, etc. stuff */
 #include "vol-salvage.h"
+#include "common.h"
 #include "vol_internal.h"
 #include <afs/acl.h>
 #include <afs/prs_fs.h>
@@ -305,8 +306,6 @@ char *tmpdir = NULL;
 
 
 /* Forward declarations */
-/*@printflike@*/ void Log(const char *format, ...);
-/*@printflike@*/ void Abort(const char *format, ...) AFS_NORETURN;
 static int IsVnodeOrphaned(VnodeId vnode);
 static int AskVolumeSummary(VolumeId singleVolumeNumber);
 
@@ -1255,7 +1254,7 @@ GetInodeSummary(FILE *inodeFile, VolumeId singleVolumeNumber)
        assert(ret == st_status);
     }
     nVolumesInInodeFile =(unsigned long)(status.st_size) / sizeof(struct InodeSummary);
-    Log("%d nVolumesInInodeFile %d \n",nVolumesInInodeFile,(unsigned long)(status.st_size));
+    Log("%d nVolumesInInodeFile %lu \n",nVolumesInInodeFile,(unsigned long)(status.st_size));
     fclose(summaryFile);
     return 0;
 }
index 8df6bd2f8ca4c4e59da673ed02318921df15aa60..93490e8431d55b39664b186a490794826a313cf6 100644 (file)
 #include "volume.h"
 #include "partition.h"
 #include "volume_inline.h"
+#include "common.h"
+
 #ifdef AFS_PTHREAD_ENV
 #include <assert.h>
 #else /* AFS_PTHREAD_ENV */
@@ -174,8 +176,6 @@ static volatile sig_atomic_t vol_disallow_salvsync = 0;
 extern void *calloc(), *realloc();
 #endif
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 /* Forward declarations */
 static Volume *attach2(Error * ec, VolId volumeId, char *path,
                       struct DiskPartition64 *partp, Volume * vp, 
index 404273afe839a723dd53dde618547808a655bfb6..7c58dad3f9b48578365cdec9d1e49e27688a0080 100644 (file)
@@ -58,6 +58,7 @@
 
 #include "volinodes.h"
 #include "vol_prototypes.h"
+#include "common.h"
 
 #ifdef AFS_AIX_ENV
 #include <sys/lockf.h>
@@ -74,8 +75,6 @@
 #define afs_open       open
 #endif /* !O_LARGEFILE */
 
-/*@printflike@*/ extern void Log(const char *format, ...);
-
 #define nFILES (sizeof (stuff)/sizeof(struct stuff))
 
 /* Note:  the volume creation functions herein leave the destroyMe flag in the