From: Andrew Deason Date: Fri, 19 Feb 2010 22:48:06 +0000 (-0600) Subject: VLockFile: add a couple of asserts X-Git-Tag: openafs-devel-1_5_73~74 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=7d7e2f2af801b734c1cb7fd3f84be419ad851348;p=packages%2Fo%2Fopenafs.git VLockFile: add a couple of asserts Add a couple of asserts to make some mistakes very obvious, such as passing in an invalid 'locktype' or unlocking more times than locking. Change-Id: Ie6e707ea515d5a6527dedc8875f0a4694b7b93c9 Reviewed-on: http://gerrit.openafs.org/1357 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear --- diff --git a/src/vol/vutil.c b/src/vol/vutil.c index 0c0269623..131039d27 100644 --- a/src/vol/vutil.c +++ b/src/vol/vutil.c @@ -1058,6 +1058,8 @@ VLockFileLock(struct VLockFile *lf, afs_uint32 offset, int locktype, int nonbloc { int code; + assert(locktype == READ_LOCK || locktype == WRITE_LOCK); + AFS_LF_LOCK(lf); if (lf->fd == INVALID_FD) { @@ -1091,6 +1093,8 @@ VLockFileUnlock(struct VLockFile *lf, afs_uint32 offset) { AFS_LF_LOCK(lf); + assert(lf->fd != INVALID_FD); + if (--lf->refcount < 1) { _VCloseFd(lf->fd); lf->fd = INVALID_FD;