@@ -37,11 +37,11 @@ - (instancetype)init { self = [super init]; - if (!of_rmutex_new(&_rmutex)) { + if (of_rmutex_new(&_rmutex) != 0) { Class c = self.class; [self release]; @throw [OFInitializationFailedException exceptionWithClass: c]; } @@ -51,12 +51,14 @@ } - (void)dealloc { if (_initialized) { - if (!of_rmutex_free(&_rmutex)) { - OF_ENSURE(errno == EBUSY); + int error = of_rmutex_free(&_rmutex); + + if (error != 0) { + OF_ENSURE(error == EBUSY); @throw [OFStillLockedException exceptionWithLock: self]; } } @@ -65,33 +67,39 @@ [super dealloc]; } - (void)lock { - if (!of_rmutex_lock(&_rmutex)) + int error = of_rmutex_lock(&_rmutex); + + if (error != 0) @throw [OFLockFailedException exceptionWithLock: self - errNo: errno]; + errNo: error]; } - (bool)tryLock { - if (!of_rmutex_trylock(&_rmutex)) { - if (errno == EBUSY) + int error = of_rmutex_trylock(&_rmutex); + + if (error != 0) { + if (error == EBUSY) return false; else @throw [OFLockFailedException exceptionWithLock: self - errNo: errno]; + errNo: error]; } return true; } - (void)unlock { - if (!of_rmutex_unlock(&_rmutex)) + int error = of_rmutex_unlock(&_rmutex); + + if (error != 0) @throw [OFUnlockFailedException exceptionWithLock: self - errNo: errno]; + errNo: error]; } - (OFString *)description { if (_name == nil)