VLockFile: add a couple of asserts
authorAndrew Deason <adeason@sinenomine.net>
Fri, 19 Feb 2010 22:48:06 +0000 (16:48 -0600)
committerDerrick Brashear <shadow@dementia.org>
Tue, 9 Mar 2010 19:06:43 +0000 (11:06 -0800)
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 <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/vol/vutil.c

index 0c02696..131039d 100644 (file)
@@ -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;