Add printf format checks to the cache manager

Add printf format checking to the afs_warn and afs_warnuser functions
and fix the fallout.

Change-Id: I81ed776308a31706bf307246c470ee409797f044
Reviewed-on: http://gerrit.openafs.org/792
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Simon Wilkinson 2009-11-07 21:19:42 +00:00 committed by Derrick Brashear
parent 8229e668de
commit d302f1e193
3 changed files with 15 additions and 13 deletions

View File

@ -243,8 +243,8 @@ afs_MemWriteUIO(afs_dcache_id_t *ainode, struct uio *uioP)
if (mceP->data == NULL) { /* no available memory */
mceP->data = oldData; /* revert back change that was made */
ReleaseWriteLock(&mceP->afs_memLock);
afs_warn("afs: afs_MemWriteBlk mem alloc failure (%d bytes)\n",
AFS_UIO_RESID(uioP) + AFS_UIO_OFFSET(uioP));
afs_warn("afs: afs_MemWriteBlk mem alloc failure (%ld bytes)\n",
(long)(AFS_UIO_RESID(uioP) + AFS_UIO_OFFSET(uioP)));
return -ENOMEM;
}

View File

@ -965,8 +965,10 @@ extern afs_int32 afs_data_pointer_to_int32(const void *p);
extern void afs_warn();
extern void afs_warnuser();
#else
extern void afs_warn(char *fmt, ...);
extern void afs_warnuser(char *fmt, ...);
extern void afs_warn(char *fmt, ...)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
extern void afs_warnuser(char *fmt, ...)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
#endif
/* afs_vcache.c */

View File

@ -206,7 +206,7 @@ afs_CheckLocks(void)
register int i;
afs_warn("Looking for locked data structures.\n");
afs_warn("conn %lx, volume %lx, user %lx, cell %lx, server %lx\n", &afs_xconn,
afs_warn("conn %p, volume %p, user %p, cell %p, server %p\n", &afs_xconn,
&afs_xvolume, &afs_xuser, &afs_xcell, &afs_xserver);
{
register struct vcache *tvc;
@ -220,9 +220,9 @@ afs_CheckLocks(void)
#else
if (VREFCOUNT(tvc))
#endif
afs_warn("Stat cache entry at %x is held\n", tvc);
afs_warn("Stat cache entry at %p is held\n", tvc);
if (CheckLock(&tvc->lock))
afs_warn("Stat entry at %x is locked\n", tvc);
afs_warn("Stat entry at %p is locked\n", tvc);
}
}
}
@ -232,10 +232,10 @@ afs_CheckLocks(void)
tdc = afs_indexTable[i];
if (tdc) {
if (tdc->refCount)
afs_warn("Disk entry %d at %x is held\n", i, tdc);
afs_warn("Disk entry %d at %p is held\n", i, tdc);
}
if (afs_indexFlags[i] & IFDataMod)
afs_warn("Disk entry %d at %x has IFDataMod flag set.\n", i,
afs_warn("Disk entry %d at %p has IFDataMod flag set.\n", i,
tdc);
}
}
@ -246,11 +246,11 @@ afs_CheckLocks(void)
for (i = 0; i < NSERVERS; i++) {
for (ts = afs_servers[i]; ts; ts = ts->next) {
if (ts->flags & SRVR_ISDOWN)
printf("Server entry %lx is marked down\n", (unsigned long)ts);
printf("Server entry %p is marked down\n", ts);
for (sa = ts->addr; sa; sa = sa->next_sa) {
for (tc = sa->conns; tc; tc = tc->next) {
if (tc->refCount)
afs_warn("conn at %x (server %x) is held\n", tc,
afs_warn("conn at %p (server %x) is held\n", tc,
sa->sa_ip);
}
}
@ -262,9 +262,9 @@ afs_CheckLocks(void)
for (i = 0; i < NVOLS; i++) {
for (tv = afs_volumes[i]; tv; tv = tv->next) {
if (CheckLock(&tv->lock))
afs_warn("volume at %x is locked\n", tv);
afs_warn("volume at %p is locked\n", tv);
if (tv->refCount)
afs_warn("volume at %x is held\n", tv);
afs_warn("volume at %p is held\n", tv);
}
}
}