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