From b0e8758b63f3864aac97bc55801db98d5e15b00f Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Mon, 25 Jan 2021 07:56:10 +0900 Subject: [PATCH] Use result instead of res for consistency (#1530) --- src/autolock.cpp | 20 ++++++++++---------- src/cache.cpp | 12 ++++++------ src/curl.cpp | 20 ++++++++++---------- src/curl_multi.cpp | 12 ++++++------ src/fdcache.cpp | 28 ++++++++++++++-------------- src/fdcache_entity.cpp | 20 ++++++++++---------- src/fdcache_page.cpp | 6 +++--- src/openssl_auth.cpp | 40 ++++++++++++++++++++-------------------- 8 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/autolock.cpp b/src/autolock.cpp index bb8b322..733d597 100644 --- a/src/autolock.cpp +++ b/src/autolock.cpp @@ -34,21 +34,21 @@ AutoLock::AutoLock(pthread_mutex_t* pmutex, Type type) : auto_mutex(pmutex) if (type == ALREADY_LOCKED) { is_lock_acquired = false; } else if (type == NO_WAIT) { - int res = pthread_mutex_trylock(auto_mutex); - if(res == 0){ + int result = pthread_mutex_trylock(auto_mutex); + if(result == 0){ is_lock_acquired = true; - }else if(res == EBUSY){ + }else if(result == EBUSY){ is_lock_acquired = false; }else{ - S3FS_PRN_CRIT("pthread_mutex_trylock returned: %d", res); + S3FS_PRN_CRIT("pthread_mutex_trylock returned: %d", result); abort(); } } else { - int res = pthread_mutex_lock(auto_mutex); - if(res == 0){ + int result = pthread_mutex_lock(auto_mutex); + if(result == 0){ is_lock_acquired = true; }else{ - S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); + S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result); abort(); } } @@ -62,9 +62,9 @@ bool AutoLock::isLockAcquired() const AutoLock::~AutoLock() { if (is_lock_acquired) { - int res = pthread_mutex_unlock(auto_mutex); - if(res != 0){ - S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); + int result = pthread_mutex_unlock(auto_mutex); + if(result != 0){ + S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result); abort(); } } diff --git a/src/cache.cpp b/src/cache.cpp index e799061..cd84498 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -159,9 +159,9 @@ StatCache::StatCache() : IsExpireTime(false), IsExpireIntervalType(false), Expir #if S3FS_PTHREAD_ERRORCHECK pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); #endif - int res; - if(0 != (res = pthread_mutex_init(&StatCache::stat_cache_lock, &attr))){ - S3FS_PRN_CRIT("failed to init stat_cache_lock: %d", res); + int result; + if(0 != (result = pthread_mutex_init(&StatCache::stat_cache_lock, &attr))){ + S3FS_PRN_CRIT("failed to init stat_cache_lock: %d", result); abort(); } }else{ @@ -173,9 +173,9 @@ StatCache::~StatCache() { if(this == StatCache::getStatCacheData()){ Clear(); - int res = pthread_mutex_destroy(&StatCache::stat_cache_lock); - if(res != 0){ - S3FS_PRN_CRIT("failed to destroy stat_cache_lock: %d", res); + int result = pthread_mutex_destroy(&StatCache::stat_cache_lock); + if(result != 0){ + S3FS_PRN_CRIT("failed to destroy stat_cache_lock: %d", result); abort(); } }else{ diff --git a/src/curl.cpp b/src/curl.cpp index bf48a09..58edb78 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -313,15 +313,15 @@ void S3fsCurl::LockCurlShare(CURL* handle, curl_lock_data nLockData, curl_lock_a return; } S3fsCurl::callback_locks_t* locks = static_cast(useptr); - int res; + int result; if(CURL_LOCK_DATA_DNS == nLockData){ - if(0 != (res = pthread_mutex_lock(&locks->dns))){ - S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); + if(0 != (result = pthread_mutex_lock(&locks->dns))){ + S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result); abort(); } }else if(CURL_LOCK_DATA_SSL_SESSION == nLockData){ - if(0 != (res = pthread_mutex_lock(&locks->ssl_session))){ - S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); + if(0 != (result = pthread_mutex_lock(&locks->ssl_session))){ + S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result); abort(); } } @@ -333,15 +333,15 @@ void S3fsCurl::UnlockCurlShare(CURL* handle, curl_lock_data nLockData, void* use return; } S3fsCurl::callback_locks_t* locks = static_cast(useptr); - int res; + int result; if(CURL_LOCK_DATA_DNS == nLockData){ - if(0 != (res = pthread_mutex_unlock(&locks->dns))){ - S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); + if(0 != (result = pthread_mutex_unlock(&locks->dns))){ + S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result); abort(); } }else if(CURL_LOCK_DATA_SSL_SESSION == nLockData){ - if(0 != (res = pthread_mutex_unlock(&locks->ssl_session))){ - S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); + if(0 != (result = pthread_mutex_unlock(&locks->ssl_session))){ + S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result); abort(); } } diff --git a/src/curl_multi.cpp b/src/curl_multi.cpp index a9f3fdd..5b3f120 100644 --- a/src/curl_multi.cpp +++ b/src/curl_multi.cpp @@ -33,23 +33,23 @@ //------------------------------------------------------------------- S3fsMultiCurl::S3fsMultiCurl(int maxParallelism) : maxParallelism(maxParallelism), SuccessCallback(NULL), RetryCallback(NULL) { - int res; + int result; pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); #if S3FS_PTHREAD_ERRORCHECK pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); #endif - if (0 != (res = pthread_mutex_init(&completed_tids_lock, &attr))) { - S3FS_PRN_ERR("could not initialize completed_tids_lock: %i", res); + if (0 != (result = pthread_mutex_init(&completed_tids_lock, &attr))) { + S3FS_PRN_ERR("could not initialize completed_tids_lock: %i", result); } } S3fsMultiCurl::~S3fsMultiCurl() { Clear(); - int res; - if(0 != (res = pthread_mutex_destroy(&completed_tids_lock))){ - S3FS_PRN_ERR("could not destroy completed_tids_lock: %i", res); + int result; + if(0 != (result = pthread_mutex_destroy(&completed_tids_lock))){ + S3FS_PRN_ERR("could not destroy completed_tids_lock: %i", result); } } diff --git a/src/fdcache.cpp b/src/fdcache.cpp index c31db18..7f75bd0 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -354,17 +354,17 @@ FdManager::FdManager() #if S3FS_PTHREAD_ERRORCHECK pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); #endif - int res; - if(0 != (res = pthread_mutex_init(&FdManager::fd_manager_lock, &attr))){ - S3FS_PRN_CRIT("failed to init fd_manager_lock: %d", res); + int result; + if(0 != (result = pthread_mutex_init(&FdManager::fd_manager_lock, &attr))){ + S3FS_PRN_CRIT("failed to init fd_manager_lock: %d", result); abort(); } - if(0 != (res = pthread_mutex_init(&FdManager::cache_cleanup_lock, &attr))){ - S3FS_PRN_CRIT("failed to init cache_cleanup_lock: %d", res); + if(0 != (result = pthread_mutex_init(&FdManager::cache_cleanup_lock, &attr))){ + S3FS_PRN_CRIT("failed to init cache_cleanup_lock: %d", result); abort(); } - if(0 != (res = pthread_mutex_init(&FdManager::reserved_diskspace_lock, &attr))){ - S3FS_PRN_CRIT("failed to init reserved_diskspace_lock: %d", res); + if(0 != (result = pthread_mutex_init(&FdManager::reserved_diskspace_lock, &attr))){ + S3FS_PRN_CRIT("failed to init reserved_diskspace_lock: %d", result); abort(); } FdManager::is_lock_init = true; @@ -384,17 +384,17 @@ FdManager::~FdManager() fent.clear(); if(FdManager::is_lock_init){ - int res; - if(0 != (res = pthread_mutex_destroy(&FdManager::fd_manager_lock))){ - S3FS_PRN_CRIT("failed to destroy fd_manager_lock: %d", res); + int result; + if(0 != (result = pthread_mutex_destroy(&FdManager::fd_manager_lock))){ + S3FS_PRN_CRIT("failed to destroy fd_manager_lock: %d", result); abort(); } - if(0 != (res = pthread_mutex_destroy(&FdManager::cache_cleanup_lock))){ - S3FS_PRN_CRIT("failed to destroy cache_cleanup_lock: %d", res); + if(0 != (result = pthread_mutex_destroy(&FdManager::cache_cleanup_lock))){ + S3FS_PRN_CRIT("failed to destroy cache_cleanup_lock: %d", result); abort(); } - if(0 != (res = pthread_mutex_destroy(&FdManager::reserved_diskspace_lock))){ - S3FS_PRN_CRIT("failed to destroy reserved_diskspace_lock: %d", res); + if(0 != (result = pthread_mutex_destroy(&FdManager::reserved_diskspace_lock))){ + S3FS_PRN_CRIT("failed to destroy reserved_diskspace_lock: %d", result); abort(); } FdManager::is_lock_init = false; diff --git a/src/fdcache_entity.cpp b/src/fdcache_entity.cpp index 0d86fa3..15043c5 100644 --- a/src/fdcache_entity.cpp +++ b/src/fdcache_entity.cpp @@ -103,13 +103,13 @@ FdEntity::FdEntity(const char* tpath, const char* cpath) : #if S3FS_PTHREAD_ERRORCHECK pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); #endif - int res; - if(0 != (res = pthread_mutex_init(&fdent_lock, &attr))){ - S3FS_PRN_CRIT("failed to init fdent_lock: %d", res); + int result; + if(0 != (result = pthread_mutex_init(&fdent_lock, &attr))){ + S3FS_PRN_CRIT("failed to init fdent_lock: %d", result); abort(); } - if(0 != (res = pthread_mutex_init(&fdent_data_lock, &attr))){ - S3FS_PRN_CRIT("failed to init fdent_data_lock: %d", res); + if(0 != (result = pthread_mutex_init(&fdent_data_lock, &attr))){ + S3FS_PRN_CRIT("failed to init fdent_data_lock: %d", result); abort(); } is_lock_init = true; @@ -120,13 +120,13 @@ FdEntity::~FdEntity() Clear(); if(is_lock_init){ - int res; - if(0 != (res = pthread_mutex_destroy(&fdent_data_lock))){ - S3FS_PRN_CRIT("failed to destroy fdent_data_lock: %d", res); + int result; + if(0 != (result = pthread_mutex_destroy(&fdent_data_lock))){ + S3FS_PRN_CRIT("failed to destroy fdent_data_lock: %d", result); abort(); } - if(0 != (res = pthread_mutex_destroy(&fdent_lock))){ - S3FS_PRN_CRIT("failed to destroy fdent_lock: %d", res); + if(0 != (result = pthread_mutex_destroy(&fdent_lock))){ + S3FS_PRN_CRIT("failed to destroy fdent_lock: %d", result); abort(); } is_lock_init = false; diff --git a/src/fdcache_page.cpp b/src/fdcache_page.cpp index cf568cf..0830baa 100644 --- a/src/fdcache_page.cpp +++ b/src/fdcache_page.cpp @@ -801,14 +801,14 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode) return true; } char* ptmp = new char[st.st_size + 1]; - int res; + int result; // 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); delete[] ptmp; return false; } - ptmp[res] = '\0'; + ptmp[result] = '\0'; std::string oneline; std::istringstream ssall(ptmp); diff --git a/src/openssl_auth.cpp b/src/openssl_auth.cpp index 59c3dc3..7d4a937 100644 --- a/src/openssl_auth.cpp +++ b/src/openssl_auth.cpp @@ -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) { if(s3fs_crypt_mutex){ - int res; + int result; if(mode & CRYPTO_LOCK){ - if(0 != (res = pthread_mutex_lock(&s3fs_crypt_mutex[pos]))){ - S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); + if(0 != (result = pthread_mutex_lock(&s3fs_crypt_mutex[pos]))){ + S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result); abort(); } }else{ - if(0 != (res = pthread_mutex_unlock(&s3fs_crypt_mutex[pos]))){ - S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); + if(0 != (result = pthread_mutex_unlock(&s3fs_crypt_mutex[pos]))){ + S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result); abort(); } } @@ -117,9 +117,9 @@ static struct CRYPTO_dynlock_value* s3fs_dyn_crypt_mutex(const char* file, int l #if S3FS_PTHREAD_ERRORCHECK pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); #endif - int res; - if(0 != (res = pthread_mutex_init(&(dyndata->dyn_mutex), &attr))){ - S3FS_PRN_CRIT("pthread_mutex_init returned: %d", res); + int result; + if(0 != (result = pthread_mutex_init(&(dyndata->dyn_mutex), &attr))){ + S3FS_PRN_CRIT("pthread_mutex_init returned: %d", result); return NULL; } 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) { if(dyndata){ - int res; + int result; if(mode & CRYPTO_LOCK){ - if(0 != (res = pthread_mutex_lock(&(dyndata->dyn_mutex)))){ - S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", res); + if(0 != (result = pthread_mutex_lock(&(dyndata->dyn_mutex)))){ + S3FS_PRN_CRIT("pthread_mutex_lock returned: %d", result); abort(); } }else{ - if(0 != (res = pthread_mutex_unlock(&(dyndata->dyn_mutex)))){ - S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", res); + if(0 != (result = pthread_mutex_unlock(&(dyndata->dyn_mutex)))){ + S3FS_PRN_CRIT("pthread_mutex_unlock returned: %d", result); 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) { if(dyndata){ - int res = pthread_mutex_destroy(&(dyndata->dyn_mutex)); - if(res != 0){ + int result = pthread_mutex_destroy(&(dyndata->dyn_mutex)); + if(result != 0){ S3FS_PRN_CRIT("failed to destroy dyn_mutex"); abort(); } @@ -173,9 +173,9 @@ bool s3fs_init_crypt_mutex() pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); #endif for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){ - int res = pthread_mutex_init(&s3fs_crypt_mutex[cnt], &attr); - if(res != 0){ - S3FS_PRN_CRIT("pthread_mutex_init returned: %d", res); + int result = pthread_mutex_init(&s3fs_crypt_mutex[cnt], &attr); + if(result != 0){ + S3FS_PRN_CRIT("pthread_mutex_init returned: %d", result); return false; } } @@ -203,8 +203,8 @@ bool s3fs_destroy_crypt_mutex() CRYPTO_set_locking_callback(NULL); for(int cnt = 0; cnt < CRYPTO_num_locks(); cnt++){ - int res = pthread_mutex_destroy(&s3fs_crypt_mutex[cnt]); - if(res != 0){ + int result = pthread_mutex_destroy(&s3fs_crypt_mutex[cnt]); + if(result != 0){ S3FS_PRN_CRIT("failed to destroy s3fs_crypt_mutex[%d]", cnt); abort(); }