Use result instead of res for consistency (#1530)

This commit is contained in:
Andrew Gaul 2021-01-25 07:56:10 +09:00 committed by GitHub
parent 6d65e30dd5
commit b0e8758b63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 79 additions and 79 deletions

View File

@ -34,21 +34,21 @@ AutoLock::AutoLock(pthread_mutex_t* pmutex, Type type) : auto_mutex(pmutex)
if (type == ALREADY_LOCKED) { if (type == ALREADY_LOCKED) {
is_lock_acquired = false; is_lock_acquired = false;
} else if (type == NO_WAIT) { } else if (type == NO_WAIT) {
int res = pthread_mutex_trylock(auto_mutex); int result = pthread_mutex_trylock(auto_mutex);
if(res == 0){ if(result == 0){
is_lock_acquired = true; is_lock_acquired = true;
}else if(res == EBUSY){ }else if(result == EBUSY){
is_lock_acquired = false; is_lock_acquired = false;
}else{ }else{
S3FS_PRN_CRIT("pthread_mutex_trylock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_trylock returned: %d", result);
abort(); abort();
} }
} else { } else {
int res = pthread_mutex_lock(auto_mutex); int result = pthread_mutex_lock(auto_mutex);
if(res == 0){ if(result == 0){
is_lock_acquired = true; is_lock_acquired = true;
}else{ }else{
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort(); abort();
} }
} }
@ -62,9 +62,9 @@ bool AutoLock::isLockAcquired() const
AutoLock::~AutoLock() AutoLock::~AutoLock()
{ {
if (is_lock_acquired) { if (is_lock_acquired) {
int res = pthread_mutex_unlock(auto_mutex); int result = pthread_mutex_unlock(auto_mutex);
if(res != 0){ if(result != 0){
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort(); abort();
} }
} }

View File

@ -159,9 +159,9 @@ StatCache::StatCache() : IsExpireTime(false), IsExpireIntervalType(false), Expir
#if S3FS_PTHREAD_ERRORCHECK #if S3FS_PTHREAD_ERRORCHECK
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
#endif #endif
int res; int result;
if(0 != (res = pthread_mutex_init(&StatCache::stat_cache_lock, &attr))){ if(0 != (result = pthread_mutex_init(&StatCache::stat_cache_lock, &attr))){
S3FS_PRN_CRIT("failed to init stat_cache_lock: %d", res); S3FS_PRN_CRIT("failed to init stat_cache_lock: %d", result);
abort(); abort();
} }
}else{ }else{
@ -173,9 +173,9 @@ StatCache::~StatCache()
{ {
if(this == StatCache::getStatCacheData()){ if(this == StatCache::getStatCacheData()){
Clear(); Clear();
int res = pthread_mutex_destroy(&StatCache::stat_cache_lock); int result = pthread_mutex_destroy(&StatCache::stat_cache_lock);
if(res != 0){ if(result != 0){
S3FS_PRN_CRIT("failed to destroy stat_cache_lock: %d", res); S3FS_PRN_CRIT("failed to destroy stat_cache_lock: %d", result);
abort(); abort();
} }
}else{ }else{

View File

@ -313,15 +313,15 @@ void S3fsCurl::LockCurlShare(CURL* handle, curl_lock_data nLockData, curl_lock_a
return; return;
} }
S3fsCurl::callback_locks_t* locks = static_cast<S3fsCurl::callback_locks_t*>(useptr); S3fsCurl::callback_locks_t* locks = static_cast<S3fsCurl::callback_locks_t*>(useptr);
int res; int result;
if(CURL_LOCK_DATA_DNS == nLockData){ if(CURL_LOCK_DATA_DNS == nLockData){
if(0 != (res = pthread_mutex_lock(&locks->dns))){ if(0 != (result = pthread_mutex_lock(&locks->dns))){
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort(); abort();
} }
}else if(CURL_LOCK_DATA_SSL_SESSION == nLockData){ }else if(CURL_LOCK_DATA_SSL_SESSION == nLockData){
if(0 != (res = pthread_mutex_lock(&locks->ssl_session))){ if(0 != (result = pthread_mutex_lock(&locks->ssl_session))){
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort(); abort();
} }
} }
@ -333,15 +333,15 @@ void S3fsCurl::UnlockCurlShare(CURL* handle, curl_lock_data nLockData, void* use
return; return;
} }
S3fsCurl::callback_locks_t* locks = static_cast<S3fsCurl::callback_locks_t*>(useptr); S3fsCurl::callback_locks_t* locks = static_cast<S3fsCurl::callback_locks_t*>(useptr);
int res; int result;
if(CURL_LOCK_DATA_DNS == nLockData){ if(CURL_LOCK_DATA_DNS == nLockData){
if(0 != (res = pthread_mutex_unlock(&locks->dns))){ if(0 != (result = pthread_mutex_unlock(&locks->dns))){
S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result);
abort(); abort();
} }
}else if(CURL_LOCK_DATA_SSL_SESSION == nLockData){ }else if(CURL_LOCK_DATA_SSL_SESSION == nLockData){
if(0 != (res = pthread_mutex_unlock(&locks->ssl_session))){ if(0 != (result = pthread_mutex_unlock(&locks->ssl_session))){
S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result);
abort(); abort();
} }
} }

View File

@ -33,23 +33,23 @@
//------------------------------------------------------------------- //-------------------------------------------------------------------
S3fsMultiCurl::S3fsMultiCurl(int maxParallelism) : maxParallelism(maxParallelism), SuccessCallback(NULL), RetryCallback(NULL) S3fsMultiCurl::S3fsMultiCurl(int maxParallelism) : maxParallelism(maxParallelism), SuccessCallback(NULL), RetryCallback(NULL)
{ {
int res; int result;
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr); pthread_mutexattr_init(&attr);
#if S3FS_PTHREAD_ERRORCHECK #if S3FS_PTHREAD_ERRORCHECK
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
#endif #endif
if (0 != (res = pthread_mutex_init(&completed_tids_lock, &attr))) { if (0 != (result = pthread_mutex_init(&completed_tids_lock, &attr))) {
S3FS_PRN_ERR("could not initialize completed_tids_lock: %i", res); S3FS_PRN_ERR("could not initialize completed_tids_lock: %i", result);
} }
} }
S3fsMultiCurl::~S3fsMultiCurl() S3fsMultiCurl::~S3fsMultiCurl()
{ {
Clear(); Clear();
int res; int result;
if(0 != (res = pthread_mutex_destroy(&completed_tids_lock))){ if(0 != (result = pthread_mutex_destroy(&completed_tids_lock))){
S3FS_PRN_ERR("could not destroy completed_tids_lock: %i", res); S3FS_PRN_ERR("could not destroy completed_tids_lock: %i", result);
} }
} }

View File

@ -354,17 +354,17 @@ FdManager::FdManager()
#if S3FS_PTHREAD_ERRORCHECK #if S3FS_PTHREAD_ERRORCHECK
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
#endif #endif
int res; int result;
if(0 != (res = pthread_mutex_init(&FdManager::fd_manager_lock, &attr))){ if(0 != (result = pthread_mutex_init(&FdManager::fd_manager_lock, &attr))){
S3FS_PRN_CRIT("failed to init fd_manager_lock: %d", res); S3FS_PRN_CRIT("failed to init fd_manager_lock: %d", result);
abort(); abort();
} }
if(0 != (res = pthread_mutex_init(&FdManager::cache_cleanup_lock, &attr))){ if(0 != (result = pthread_mutex_init(&FdManager::cache_cleanup_lock, &attr))){
S3FS_PRN_CRIT("failed to init cache_cleanup_lock: %d", res); S3FS_PRN_CRIT("failed to init cache_cleanup_lock: %d", result);
abort(); abort();
} }
if(0 != (res = pthread_mutex_init(&FdManager::reserved_diskspace_lock, &attr))){ if(0 != (result = pthread_mutex_init(&FdManager::reserved_diskspace_lock, &attr))){
S3FS_PRN_CRIT("failed to init reserved_diskspace_lock: %d", res); S3FS_PRN_CRIT("failed to init reserved_diskspace_lock: %d", result);
abort(); abort();
} }
FdManager::is_lock_init = true; FdManager::is_lock_init = true;
@ -384,17 +384,17 @@ FdManager::~FdManager()
fent.clear(); fent.clear();
if(FdManager::is_lock_init){ if(FdManager::is_lock_init){
int res; int result;
if(0 != (res = pthread_mutex_destroy(&FdManager::fd_manager_lock))){ if(0 != (result = pthread_mutex_destroy(&FdManager::fd_manager_lock))){
S3FS_PRN_CRIT("failed to destroy fd_manager_lock: %d", res); S3FS_PRN_CRIT("failed to destroy fd_manager_lock: %d", result);
abort(); abort();
} }
if(0 != (res = pthread_mutex_destroy(&FdManager::cache_cleanup_lock))){ if(0 != (result = pthread_mutex_destroy(&FdManager::cache_cleanup_lock))){
S3FS_PRN_CRIT("failed to destroy cache_cleanup_lock: %d", res); S3FS_PRN_CRIT("failed to destroy cache_cleanup_lock: %d", result);
abort(); abort();
} }
if(0 != (res = pthread_mutex_destroy(&FdManager::reserved_diskspace_lock))){ if(0 != (result = pthread_mutex_destroy(&FdManager::reserved_diskspace_lock))){
S3FS_PRN_CRIT("failed to destroy reserved_diskspace_lock: %d", res); S3FS_PRN_CRIT("failed to destroy reserved_diskspace_lock: %d", result);
abort(); abort();
} }
FdManager::is_lock_init = false; FdManager::is_lock_init = false;

View File

@ -103,13 +103,13 @@ FdEntity::FdEntity(const char* tpath, const char* cpath) :
#if S3FS_PTHREAD_ERRORCHECK #if S3FS_PTHREAD_ERRORCHECK
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
#endif #endif
int res; int result;
if(0 != (res = pthread_mutex_init(&fdent_lock, &attr))){ if(0 != (result = pthread_mutex_init(&fdent_lock, &attr))){
S3FS_PRN_CRIT("failed to init fdent_lock: %d", res); S3FS_PRN_CRIT("failed to init fdent_lock: %d", result);
abort(); abort();
} }
if(0 != (res = pthread_mutex_init(&fdent_data_lock, &attr))){ if(0 != (result = pthread_mutex_init(&fdent_data_lock, &attr))){
S3FS_PRN_CRIT("failed to init fdent_data_lock: %d", res); S3FS_PRN_CRIT("failed to init fdent_data_lock: %d", result);
abort(); abort();
} }
is_lock_init = true; is_lock_init = true;
@ -120,13 +120,13 @@ FdEntity::~FdEntity()
Clear(); Clear();
if(is_lock_init){ if(is_lock_init){
int res; int result;
if(0 != (res = pthread_mutex_destroy(&fdent_data_lock))){ if(0 != (result = pthread_mutex_destroy(&fdent_data_lock))){
S3FS_PRN_CRIT("failed to destroy fdent_data_lock: %d", res); S3FS_PRN_CRIT("failed to destroy fdent_data_lock: %d", result);
abort(); abort();
} }
if(0 != (res = pthread_mutex_destroy(&fdent_lock))){ if(0 != (result = pthread_mutex_destroy(&fdent_lock))){
S3FS_PRN_CRIT("failed to destroy fdent_lock: %d", res); S3FS_PRN_CRIT("failed to destroy fdent_lock: %d", result);
abort(); abort();
} }
is_lock_init = false; is_lock_init = false;

View File

@ -801,14 +801,14 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode)
return true; return true;
} }
char* ptmp = new char[st.st_size + 1]; char* ptmp = new char[st.st_size + 1];
int res; int result;
// read from file // read from file
if(0 >= (res = pread(file.GetFd(), ptmp, st.st_size, 0))){ if(0 >= (result = pread(file.GetFd(), ptmp, st.st_size, 0))){
S3FS_PRN_ERR("failed to read stats(%d)", errno); S3FS_PRN_ERR("failed to read stats(%d)", errno);
delete[] ptmp; delete[] ptmp;
return false; return false;
} }
ptmp[res] = '\0'; ptmp[result] = '\0';
std::string oneline; std::string oneline;
std::istringstream ssall(ptmp); std::istringstream ssall(ptmp);

View File

@ -85,15 +85,15 @@ static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line)
static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line) static void s3fs_crypt_mutex_lock(int mode, int pos, const char* file, int line)
{ {
if(s3fs_crypt_mutex){ if(s3fs_crypt_mutex){
int res; int result;
if(mode & CRYPTO_LOCK){ if(mode & CRYPTO_LOCK){
if(0 != (res = pthread_mutex_lock(&s3fs_crypt_mutex[pos]))){ if(0 != (result = pthread_mutex_lock(&s3fs_crypt_mutex[pos]))){
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort(); abort();
} }
}else{ }else{
if(0 != (res = pthread_mutex_unlock(&s3fs_crypt_mutex[pos]))){ if(0 != (result = pthread_mutex_unlock(&s3fs_crypt_mutex[pos]))){
S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result);
abort(); abort();
} }
} }
@ -117,9 +117,9 @@ static struct CRYPTO_dynlock_value* s3fs_dyn_crypt_mutex(const char* file, int l
#if S3FS_PTHREAD_ERRORCHECK #if S3FS_PTHREAD_ERRORCHECK
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
#endif #endif
int res; int result;
if(0 != (res = pthread_mutex_init(&(dyndata->dyn_mutex), &attr))){ if(0 != (result = pthread_mutex_init(&(dyndata->dyn_mutex), &attr))){
S3FS_PRN_CRIT("pthread_mutex_init returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_init returned: %d", result);
return NULL; return NULL;
} }
return dyndata; return dyndata;
@ -129,15 +129,15 @@ static void s3fs_dyn_crypt_mutex_lock(int mode, struct CRYPTO_dynlock_value* dyn
static void s3fs_dyn_crypt_mutex_lock(int mode, struct CRYPTO_dynlock_value* dyndata, const char* file, int line) static void s3fs_dyn_crypt_mutex_lock(int mode, struct CRYPTO_dynlock_value* dyndata, const char* file, int line)
{ {
if(dyndata){ if(dyndata){
int res; int result;
if(mode & CRYPTO_LOCK){ if(mode & CRYPTO_LOCK){
if(0 != (res = pthread_mutex_lock(&(dyndata->dyn_mutex)))){ if(0 != (result = pthread_mutex_lock(&(dyndata->dyn_mutex)))){
S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result);
abort(); abort();
} }
}else{ }else{
if(0 != (res = pthread_mutex_unlock(&(dyndata->dyn_mutex)))){ if(0 != (result = pthread_mutex_unlock(&(dyndata->dyn_mutex)))){
S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result);
abort(); abort();
} }
} }
@ -148,8 +148,8 @@ static void s3fs_destroy_dyn_crypt_mutex(struct CRYPTO_dynlock_value* dyndata, c
static void s3fs_destroy_dyn_crypt_mutex(struct CRYPTO_dynlock_value* dyndata, const char* file, int line) static void s3fs_destroy_dyn_crypt_mutex(struct CRYPTO_dynlock_value* dyndata, const char* file, int line)
{ {
if(dyndata){ if(dyndata){
int res = pthread_mutex_destroy(&(dyndata->dyn_mutex)); int result = pthread_mutex_destroy(&(dyndata->dyn_mutex));
if(res != 0){ if(result != 0){
S3FS_PRN_CRIT("failed to destroy dyn_mutex"); S3FS_PRN_CRIT("failed to destroy dyn_mutex");
abort(); abort();
} }
@ -173,9 +173,9 @@ bool s3fs_init_crypt_mutex()
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
#endif #endif
for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){ for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){
int res = pthread_mutex_init(&s3fs_crypt_mutex[cnt], &attr); int result = pthread_mutex_init(&s3fs_crypt_mutex[cnt], &attr);
if(res != 0){ if(result != 0){
S3FS_PRN_CRIT("pthread_mutex_init returned: %d", res); S3FS_PRN_CRIT("pthread_mutex_init returned: %d", result);
return false; return false;
} }
} }
@ -203,8 +203,8 @@ bool s3fs_destroy_crypt_mutex()
CRYPTO_set_locking_callback(NULL); CRYPTO_set_locking_callback(NULL);
for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){ for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){
int res = pthread_mutex_destroy(&s3fs_crypt_mutex[cnt]); int result = pthread_mutex_destroy(&s3fs_crypt_mutex[cnt]);
if(res != 0){ if(result != 0){
S3FS_PRN_CRIT("failed to destroy s3fs_crypt_mutex[%d]", cnt); S3FS_PRN_CRIT("failed to destroy s3fs_crypt_mutex[%d]", cnt);
abort(); abort();
} }