From 7d7e2f2af801b734c1cb7fd3f84be419ad851348 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 19 Feb 2010 16:48:06 -0600 Subject: [PATCH] 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 --- src/vol/vutil.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vol/vutil.c b/src/vol/vutil.c index 0c02696..131039d 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; -- 1.9.4