Merge pull request #1414 from gaul/clang-tidy/misc

Fix clang-tidy warnings
This commit is contained in:
Takeshi Nakatani 2020-09-21 07:49:59 +09:00 committed by GitHub
commit 864941d4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 146 additions and 147 deletions

View File

@ -53,14 +53,14 @@ class AdditionalHeader
public: public:
// Reference singleton // Reference singleton
static AdditionalHeader* get(void) { return &singleton; } static AdditionalHeader* get() { return &singleton; }
bool Load(const char* file); bool Load(const char* file);
void Unload(void); void Unload();
bool AddHeader(headers_t& meta, const char* path) const; bool AddHeader(headers_t& meta, const char* path) const;
struct curl_slist* AddHeader(struct curl_slist* list, const char* path) const; struct curl_slist* AddHeader(struct curl_slist* list, const char* path) const;
bool Dump(void) const; bool Dump() const;
}; };
#endif // S3FS_ADDHEAD_H_ #endif // S3FS_ADDHEAD_H_

View File

@ -47,7 +47,7 @@ class BodyData
Clear(); Clear();
} }
void Clear(void); void Clear();
bool Append(void* ptr, size_t bytes); bool Append(void* ptr, size_t bytes);
bool Append(void* ptr, size_t blockSize, size_t numBlocks) bool Append(void* ptr, size_t blockSize, size_t numBlocks)
{ {

View File

@ -95,36 +95,36 @@ class StatCache
StatCache(); StatCache();
~StatCache(); ~StatCache();
void Clear(void); void Clear();
bool GetStat(const std::string& key, struct stat* pst, headers_t* meta, bool overcheck, const char* petag, bool* pisforce); bool GetStat(const std::string& key, struct stat* pst, headers_t* meta, bool overcheck, const char* petag, bool* pisforce);
// Truncate stat cache // Truncate stat cache
bool TruncateCache(void); bool TruncateCache();
// Truncate symbolic link cache // Truncate symbolic link cache
bool TruncateSymlink(void); bool TruncateSymlink();
public: public:
// Reference singleton // Reference singleton
static StatCache* getStatCacheData(void) static StatCache* getStatCacheData()
{ {
return &singleton; return &singleton;
} }
// Attribute // Attribute
unsigned long GetCacheSize(void) const; unsigned long GetCacheSize() const;
unsigned long SetCacheSize(unsigned long size); unsigned long SetCacheSize(unsigned long size);
time_t GetExpireTime(void) const; time_t GetExpireTime() const;
time_t SetExpireTime(time_t expire, bool is_interval = false); time_t SetExpireTime(time_t expire, bool is_interval = false);
time_t UnsetExpireTime(void); time_t UnsetExpireTime();
bool SetCacheNoObject(bool flag); bool SetCacheNoObject(bool flag);
bool EnableCacheNoObject(void) bool EnableCacheNoObject()
{ {
return SetCacheNoObject(true); return SetCacheNoObject(true);
} }
bool DisableCacheNoObject(void) bool DisableCacheNoObject()
{ {
return SetCacheNoObject(false); return SetCacheNoObject(false);
} }
bool GetCacheNoObject(void) const bool GetCacheNoObject() const
{ {
return IsCacheNoObject; return IsCacheNoObject;
} }

View File

@ -203,17 +203,17 @@ class S3fsCurl
private: private:
// class methods // class methods
static bool InitGlobalCurl(void); static bool InitGlobalCurl();
static bool DestroyGlobalCurl(void); static bool DestroyGlobalCurl();
static bool InitShareCurl(void); static bool InitShareCurl();
static bool DestroyShareCurl(void); static bool DestroyShareCurl();
static void LockCurlShare(CURL* handle, curl_lock_data nLockData, curl_lock_access laccess, void* useptr); static void LockCurlShare(CURL* handle, curl_lock_data nLockData, curl_lock_access laccess, void* useptr);
static void UnlockCurlShare(CURL* handle, curl_lock_data nLockData, void* useptr); static void UnlockCurlShare(CURL* handle, curl_lock_data nLockData, void* useptr);
static bool InitCryptMutex(void); static bool InitCryptMutex();
static bool DestroyCryptMutex(void); static bool DestroyCryptMutex();
static int CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); static int CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
static bool LocateBundle(void); static bool LocateBundle();
static size_t HeaderCallback(void *data, size_t blockSize, size_t numBlocks, void *userPtr); static size_t HeaderCallback(void *data, size_t blockSize, size_t numBlocks, void *userPtr);
static size_t WriteMemoryCallback(void *ptr, size_t blockSize, size_t numBlocks, void *data); static size_t WriteMemoryCallback(void *ptr, size_t blockSize, size_t numBlocks, void *data);
static size_t ReadCallback(void *ptr, size_t size, size_t nmemb, void *userp); static size_t ReadCallback(void *ptr, size_t size, size_t nmemb, void *userp);
@ -238,8 +238,8 @@ class S3fsCurl
static bool SetIAMCredentials(const char* response); static bool SetIAMCredentials(const char* response);
static bool ParseIAMRoleFromMetaDataResponse(const char* response, std::string& rolename); static bool ParseIAMRoleFromMetaDataResponse(const char* response, std::string& rolename);
static bool SetIAMRoleFromMetaData(const char* response); static bool SetIAMRoleFromMetaData(const char* response);
static bool LoadEnvSseCKeys(void); static bool LoadEnvSseCKeys();
static bool LoadEnvSseKmsid(void); static bool LoadEnvSseKmsid();
static bool PushbackSseKeys(std::string& onekey); static bool PushbackSseKeys(std::string& onekey);
static bool AddUserAgent(CURL* hCurl); static bool AddUserAgent(CURL* hCurl);
@ -250,15 +250,15 @@ class S3fsCurl
// methods // methods
bool ResetHandle(bool lock_already_held = false); bool ResetHandle(bool lock_already_held = false);
bool RemakeHandle(void); bool RemakeHandle();
bool ClearInternalData(void); bool ClearInternalData();
void insertV4Headers(); void insertV4Headers();
void insertV2Headers(); void insertV2Headers();
void insertIBMIAMHeaders(); void insertIBMIAMHeaders();
void insertAuthHeaders(); void insertAuthHeaders();
std::string CalcSignatureV2(const std::string& method, const std::string& strMD5, const std::string& content_type, const std::string& date, const std::string& resource); std::string CalcSignatureV2(const std::string& method, const std::string& strMD5, const std::string& content_type, const std::string& date, const std::string& resource);
std::string CalcSignature(const std::string& method, const std::string& canonical_uri, const std::string& query_string, const std::string& strdate, const std::string& payload_hash, const std::string& date8601); std::string CalcSignature(const std::string& method, const std::string& canonical_uri, const std::string& query_string, const std::string& strdate, const std::string& payload_hash, const std::string& date8601);
int GetIAMCredentials(void); int GetIAMCredentials();
int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id); int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id);
int CopyMultipartPostSetup(const char* from, const char* to, int part_num, const std::string& upload_id, headers_t& meta); int CopyMultipartPostSetup(const char* from, const char* to, int part_num, const std::string& upload_id, headers_t& meta);
@ -268,13 +268,13 @@ class S3fsCurl
public: public:
// class methods // class methods
static bool InitS3fsCurl(void); static bool InitS3fsCurl();
static bool InitMimeType(const std::string& strFile); static bool InitMimeType(const std::string& strFile);
static bool DestroyS3fsCurl(void); static bool DestroyS3fsCurl();
static int ParallelMultipartUploadRequest(const char* tpath, headers_t& meta, int fd); static int ParallelMultipartUploadRequest(const char* tpath, headers_t& meta, int fd);
static int ParallelMixMultipartUploadRequest(const char* tpath, headers_t& meta, int fd, const fdpage_list_t& mixuppages); static int ParallelMixMultipartUploadRequest(const char* tpath, headers_t& meta, int fd, const fdpage_list_t& mixuppages);
static int ParallelGetObjectRequest(const char* tpath, int fd, off_t start, off_t size); static int ParallelGetObjectRequest(const char* tpath, int fd, off_t start, off_t size);
static bool CheckIAMCredentialUpdate(void); static bool CheckIAMCredentialUpdate();
// class methods(variables) // class methods(variables)
static std::string LookupMimeType(const std::string& name); static std::string LookupMimeType(const std::string& name);
@ -283,52 +283,52 @@ class S3fsCurl
static bool SetSslSessionCache(bool isCache); static bool SetSslSessionCache(bool isCache);
static long SetConnectTimeout(long timeout); static long SetConnectTimeout(long timeout);
static time_t SetReadwriteTimeout(time_t timeout); static time_t SetReadwriteTimeout(time_t timeout);
static time_t GetReadwriteTimeout(void) { return S3fsCurl::readwrite_timeout; } static time_t GetReadwriteTimeout() { return S3fsCurl::readwrite_timeout; }
static int SetRetries(int count); static int SetRetries(int count);
static bool SetPublicBucket(bool flag); static bool SetPublicBucket(bool flag);
static bool IsPublicBucket(void) { return S3fsCurl::is_public_bucket; } static bool IsPublicBucket() { return S3fsCurl::is_public_bucket; }
static acl_t SetDefaultAcl(acl_t acl); static acl_t SetDefaultAcl(acl_t acl);
static acl_t GetDefaultAcl(); static acl_t GetDefaultAcl();
static storage_class_t SetStorageClass(storage_class_t storage_class); static storage_class_t SetStorageClass(storage_class_t storage_class);
static storage_class_t GetStorageClass() { return S3fsCurl::storage_class; } static storage_class_t GetStorageClass() { return S3fsCurl::storage_class; }
static bool LoadEnvSse(void) { return (S3fsCurl::LoadEnvSseCKeys() && S3fsCurl::LoadEnvSseKmsid()); } static bool LoadEnvSse() { return (S3fsCurl::LoadEnvSseCKeys() && S3fsCurl::LoadEnvSseKmsid()); }
static sse_type_t SetSseType(sse_type_t type); static sse_type_t SetSseType(sse_type_t type);
static sse_type_t GetSseType(void) { return S3fsCurl::ssetype; } static sse_type_t GetSseType() { return S3fsCurl::ssetype; }
static bool IsSseDisable(void) { return (sse_type_t::SSE_DISABLE == S3fsCurl::ssetype); } static bool IsSseDisable() { return (sse_type_t::SSE_DISABLE == S3fsCurl::ssetype); }
static bool IsSseS3Type(void) { return (sse_type_t::SSE_S3 == S3fsCurl::ssetype); } static bool IsSseS3Type() { return (sse_type_t::SSE_S3 == S3fsCurl::ssetype); }
static bool IsSseCType(void) { return (sse_type_t::SSE_C == S3fsCurl::ssetype); } static bool IsSseCType() { return (sse_type_t::SSE_C == S3fsCurl::ssetype); }
static bool IsSseKmsType(void) { return (sse_type_t::SSE_KMS == S3fsCurl::ssetype); } static bool IsSseKmsType() { return (sse_type_t::SSE_KMS == S3fsCurl::ssetype); }
static bool FinalCheckSse(void); static bool FinalCheckSse();
static bool SetSseCKeys(const char* filepath); static bool SetSseCKeys(const char* filepath);
static bool SetSseKmsid(const char* kmsid); static bool SetSseKmsid(const char* kmsid);
static bool IsSetSseKmsId(void) { return !S3fsCurl::ssekmsid.empty(); } static bool IsSetSseKmsId() { return !S3fsCurl::ssekmsid.empty(); }
static const char* GetSseKmsId(void) { return S3fsCurl::ssekmsid.c_str(); } static const char* GetSseKmsId() { return S3fsCurl::ssekmsid.c_str(); }
static bool GetSseKey(std::string& md5, std::string& ssekey); static bool GetSseKey(std::string& md5, std::string& ssekey);
static bool GetSseKeyMd5(int pos, std::string& md5); static bool GetSseKeyMd5(int pos, std::string& md5);
static int GetSseKeyCount(void); static int GetSseKeyCount();
static bool SetContentMd5(bool flag); static bool SetContentMd5(bool flag);
static bool SetVerbose(bool flag); static bool SetVerbose(bool flag);
static bool GetVerbose(void) { return S3fsCurl::is_verbose; } static bool GetVerbose() { return S3fsCurl::is_verbose; }
static bool SetDumpBody(bool flag); static bool SetDumpBody(bool flag);
static bool IsDumpBody(void) { return S3fsCurl::is_dump_body; } static bool IsDumpBody() { return S3fsCurl::is_dump_body; }
static bool SetAccessKey(const char* AccessKeyId, const char* SecretAccessKey); static bool SetAccessKey(const char* AccessKeyId, const char* SecretAccessKey);
static bool SetAccessKeyWithSessionToken(const char* AccessKeyId, const char* SecretAccessKey, const char * SessionToken); static bool SetAccessKeyWithSessionToken(const char* AccessKeyId, const char* SecretAccessKey, const char * SessionToken);
static bool IsSetAccessKeyID(void) static bool IsSetAccessKeyID()
{ {
return (0 < S3fsCurl::AWSAccessKeyId.size()); return (0 < S3fsCurl::AWSAccessKeyId.size());
} }
static bool IsSetAccessKeys(void) static bool IsSetAccessKeys()
{ {
return (0 < S3fsCurl::IAM_role.size() || ((0 < S3fsCurl::AWSAccessKeyId.size() || S3fsCurl::is_ibm_iam_auth) && 0 < S3fsCurl::AWSSecretAccessKey.size())); return (0 < S3fsCurl::IAM_role.size() || ((0 < S3fsCurl::AWSAccessKeyId.size() || S3fsCurl::is_ibm_iam_auth) && 0 < S3fsCurl::AWSSecretAccessKey.size()));
} }
static long SetSslVerifyHostname(long value); static long SetSslVerifyHostname(long value);
static long GetSslVerifyHostname(void) { return S3fsCurl::ssl_verify_hostname; } static long GetSslVerifyHostname() { return S3fsCurl::ssl_verify_hostname; }
// maximum parallel GET and PUT requests // maximum parallel GET and PUT requests
static int SetMaxParallelCount(int value); static int SetMaxParallelCount(int value);
static int GetMaxParallelCount(void) { return S3fsCurl::max_parallel_cnt; } static int GetMaxParallelCount() { return S3fsCurl::max_parallel_cnt; }
// maximum parallel HEAD requests // maximum parallel HEAD requests
static int SetMaxMultiRequest(int max); static int SetMaxMultiRequest(int max);
static int GetMaxMultiRequest(void) { return S3fsCurl::max_multireq; } static int GetMaxMultiRequest() { return S3fsCurl::max_multireq; }
static bool SetIsECS(bool flag); static bool SetIsECS(bool flag);
static bool SetIsIBMIAMAuth(bool flag); static bool SetIsIBMIAMAuth(bool flag);
static size_t SetIAMFieldCount(size_t field_count); static size_t SetIAMFieldCount(size_t field_count);
@ -336,22 +336,22 @@ class S3fsCurl
static std::string SetIAMTokenField(const char* token_field); static std::string SetIAMTokenField(const char* token_field);
static std::string SetIAMExpiryField(const char* expiry_field); static std::string SetIAMExpiryField(const char* expiry_field);
static std::string SetIAMRole(const char* role); static std::string SetIAMRole(const char* role);
static const char* GetIAMRole(void) { return S3fsCurl::IAM_role.c_str(); } static const char* GetIAMRole() { return S3fsCurl::IAM_role.c_str(); }
static bool SetMultipartSize(off_t size); static bool SetMultipartSize(off_t size);
static off_t GetMultipartSize(void) { return S3fsCurl::multipart_size; } static off_t GetMultipartSize() { return S3fsCurl::multipart_size; }
static bool SetSignatureV4(bool isset) { bool bresult = S3fsCurl::is_sigv4; S3fsCurl::is_sigv4 = isset; return bresult; } static bool SetSignatureV4(bool isset) { bool bresult = S3fsCurl::is_sigv4; S3fsCurl::is_sigv4 = isset; return bresult; }
static bool IsSignatureV4(void) { return S3fsCurl::is_sigv4; } static bool IsSignatureV4() { return S3fsCurl::is_sigv4; }
static bool SetUserAgentFlag(bool isset) { bool bresult = S3fsCurl::is_ua; S3fsCurl::is_ua = isset; return bresult; } static bool SetUserAgentFlag(bool isset) { bool bresult = S3fsCurl::is_ua; S3fsCurl::is_ua = isset; return bresult; }
static bool IsUserAgentFlag(void) { return S3fsCurl::is_ua; } static bool IsUserAgentFlag() { return S3fsCurl::is_ua; }
static void InitUserAgent(void); static void InitUserAgent();
static bool SetRequesterPays(bool flag) { bool old_flag = S3fsCurl::requester_pays; S3fsCurl::requester_pays = flag; return old_flag; } static bool SetRequesterPays(bool flag) { bool old_flag = S3fsCurl::requester_pays; S3fsCurl::requester_pays = flag; return old_flag; }
static bool IsRequesterPays(void) { return S3fsCurl::requester_pays; } static bool IsRequesterPays() { return S3fsCurl::requester_pays; }
// methods // methods
bool CreateCurlHandle(bool only_pool = false, bool remake = false); bool CreateCurlHandle(bool only_pool = false, bool remake = false);
bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true); bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true);
bool LoadIAMRoleFromMetaData(void); bool LoadIAMRoleFromMetaData();
bool AddSseRequestHead(sse_type_t ssetype, std::string& ssevalue, bool is_only_c, bool is_copy); bool AddSseRequestHead(sse_type_t ssetype, std::string& ssevalue, bool is_only_c, bool is_copy);
bool GetResponseCode(long& responseCode, bool from_curl_handle = true); bool GetResponseCode(long& responseCode, bool from_curl_handle = true);
int RequestPerform(bool dontAddAuthHeaders=false); int RequestPerform(bool dontAddAuthHeaders=false);
@ -365,7 +365,7 @@ class S3fsCurl
int PutRequest(const char* tpath, headers_t& meta, int fd); int PutRequest(const char* tpath, headers_t& meta, int fd);
int PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, std::string& ssevalue); int PreGetObjectRequest(const char* tpath, int fd, off_t start, off_t size, sse_type_t ssetype, std::string& ssevalue);
int GetObjectRequest(const char* tpath, int fd, off_t start = -1, off_t size = -1); int GetObjectRequest(const char* tpath, int fd, off_t start = -1, off_t size = -1);
int CheckBucket(void); int CheckBucket();
int ListBucketRequest(const char* tpath, const char* query); int ListBucketRequest(const char* tpath, const char* query);
int PreMultipartPostRequest(const char* tpath, headers_t& meta, std::string& upload_id, bool is_copy); int PreMultipartPostRequest(const char* tpath, headers_t& meta, std::string& upload_id, bool is_copy);
int CompleteMultipartPostRequest(const char* tpath, const std::string& upload_id, etaglist_t& parts); int CompleteMultipartPostRequest(const char* tpath, const std::string& upload_id, etaglist_t& parts);
@ -378,24 +378,24 @@ class S3fsCurl
int MultipartRenameRequest(const char* from, const char* to, headers_t& meta, off_t size); int MultipartRenameRequest(const char* from, const char* to, headers_t& meta, off_t size);
// methods(variables) // methods(variables)
CURL* GetCurlHandle(void) const { return hCurl; } CURL* GetCurlHandle() const { return hCurl; }
std::string GetPath(void) const { return path; } std::string GetPath() const { return path; }
std::string GetBasePath(void) const { return base_path; } std::string GetBasePath() const { return base_path; }
std::string GetSpacialSavedPath(void) const { return saved_path; } std::string GetSpacialSavedPath() const { return saved_path; }
std::string GetUrl(void) const { return url; } std::string GetUrl() const { return url; }
std::string GetOp(void) const { return op; } std::string GetOp() const { return op; }
headers_t* GetResponseHeaders(void) { return &responseHeaders; } headers_t* GetResponseHeaders() { return &responseHeaders; }
BodyData* GetBodyData(void) { return &bodydata; } BodyData* GetBodyData() { return &bodydata; }
BodyData* GetHeadData(void) { return &headdata; } BodyData* GetHeadData() { return &headdata; }
long GetLastResponseCode(void) const { return LastResponseCode; } long GetLastResponseCode() const { return LastResponseCode; }
bool SetUseAhbe(bool ahbe); bool SetUseAhbe(bool ahbe);
bool EnableUseAhbe(void) { return SetUseAhbe(true); } bool EnableUseAhbe() { return SetUseAhbe(true); }
bool DisableUseAhbe(void) { return SetUseAhbe(false); } bool DisableUseAhbe() { return SetUseAhbe(false); }
bool IsUseAhbe(void) const { return is_use_ahbe; } bool IsUseAhbe() const { return is_use_ahbe; }
int GetMultipartRetryCount(void) const { return retry_count; } int GetMultipartRetryCount() const { return retry_count; }
void SetMultipartRetryCount(int retrycnt) { retry_count = retrycnt; } void SetMultipartRetryCount(int retrycnt) { retry_count = retrycnt; }
bool IsOverMultipartRetryCount(void) const { return (retry_count >= S3fsCurl::retries); } bool IsOverMultipartRetryCount() const { return (retry_count >= S3fsCurl::retries); }
int GetLastPreHeadSeecKeyPos(void) const { return b_ssekey_pos; } int GetLastPreHeadSeecKeyPos() const { return b_ssekey_pos; }
}; };
#endif // S3FS_CURL_H_ #endif // S3FS_CURL_H_

View File

@ -49,8 +49,8 @@ class S3fsMultiCurl
private: private:
bool ClearEx(bool is_all); bool ClearEx(bool is_all);
int MultiPerform(void); int MultiPerform();
int MultiRead(void); int MultiRead();
static void* RequestPerformWrapper(void* arg); static void* RequestPerformWrapper(void* arg);
@ -62,9 +62,9 @@ class S3fsMultiCurl
S3fsMultiSuccessCallback SetSuccessCallback(S3fsMultiSuccessCallback function); S3fsMultiSuccessCallback SetSuccessCallback(S3fsMultiSuccessCallback function);
S3fsMultiRetryCallback SetRetryCallback(S3fsMultiRetryCallback function); S3fsMultiRetryCallback SetRetryCallback(S3fsMultiRetryCallback function);
bool Clear(void) { return ClearEx(true); } bool Clear() { return ClearEx(true); }
bool SetS3fsCurlObject(S3fsCurl* s3fscurl); bool SetS3fsCurlObject(S3fsCurl* s3fscurl);
int Request(void); int Request();
}; };
#endif // S3FS_CURL_MULTI_H_ #endif // S3FS_CURL_MULTI_H_

View File

@ -40,7 +40,7 @@ bool get_object_sse_type(const char* path, sse_type_t& ssetype, std::string& sse
bool make_md5_from_binary(const char* pstr, size_t length, std::string& md5); bool make_md5_from_binary(const char* pstr, size_t length, std::string& md5);
std::string url_to_host(const std::string &url); std::string url_to_host(const std::string &url);
std::string get_bucket_host(void); std::string get_bucket_host();
const char* getCurlDebugHead(curl_infotype type); const char* getCurlDebugHead(curl_infotype type);
bool etag_equals(std::string s1, std::string s2); bool etag_equals(std::string s1, std::string s2);

View File

@ -306,7 +306,7 @@ bool FdManager::IsSafeDiskSpace(const char* path, off_t size)
return size + FdManager::GetEnsureFreeDiskSpace() <= fsize; return size + FdManager::GetEnsureFreeDiskSpace() <= fsize;
} }
bool FdManager::HaveLseekHole(void) bool FdManager::HaveLseekHole()
{ {
if(FdManager::checked_lseek){ if(FdManager::checked_lseek){
return FdManager::have_lseek_hole; return FdManager::have_lseek_hole;

View File

@ -53,27 +53,27 @@ class FdManager
~FdManager(); ~FdManager();
// Reference singleton // Reference singleton
static FdManager* get(void) { return &singleton; } static FdManager* get() { return &singleton; }
static bool DeleteCacheDirectory(void); static bool DeleteCacheDirectory();
static int DeleteCacheFile(const char* path); static int DeleteCacheFile(const char* path);
static bool SetCacheDir(const char* dir); static bool SetCacheDir(const char* dir);
static bool IsCacheDir(void) { return !FdManager::cache_dir.empty(); } static bool IsCacheDir() { return !FdManager::cache_dir.empty(); }
static const char* GetCacheDir(void) { return FdManager::cache_dir.c_str(); } static const char* GetCacheDir() { return FdManager::cache_dir.c_str(); }
static bool SetCacheCheckOutput(const char* path); static bool SetCacheCheckOutput(const char* path);
static const char* GetCacheCheckOutput(void) { return FdManager::check_cache_output.c_str(); } static const char* GetCacheCheckOutput() { return FdManager::check_cache_output.c_str(); }
static bool MakeCachePath(const char* path, std::string& cache_path, bool is_create_dir = true, bool is_mirror_path = false); static bool MakeCachePath(const char* path, std::string& cache_path, bool is_create_dir = true, bool is_mirror_path = false);
static bool CheckCacheTopDir(void); static bool CheckCacheTopDir();
static bool MakeRandomTempPath(const char* path, std::string& tmppath); static bool MakeRandomTempPath(const char* path, std::string& tmppath);
static bool SetCheckCacheDirExist(bool is_check); static bool SetCheckCacheDirExist(bool is_check);
static bool CheckCacheDirExist(void); static bool CheckCacheDirExist();
static off_t GetEnsureFreeDiskSpace(); static off_t GetEnsureFreeDiskSpace();
static off_t SetEnsureFreeDiskSpace(off_t size); static off_t SetEnsureFreeDiskSpace(off_t size);
static bool IsSafeDiskSpace(const char* path, off_t size); static bool IsSafeDiskSpace(const char* path, off_t size);
static void FreeReservedDiskSpace(off_t size); static void FreeReservedDiskSpace(off_t size);
static bool ReserveDiskSpace(off_t size); static bool ReserveDiskSpace(off_t size);
static bool HaveLseekHole(void); static bool HaveLseekHole();
// Return FdEntity associated with path, returning NULL on error. This operation increments the reference count; callers must decrement via Close after use. // Return FdEntity associated with path, returning NULL on error. This operation increments the reference count; callers must decrement via Close after use.
FdEntity* GetFdEntity(const char* path, int existfd = -1, bool increase_ref = true); FdEntity* GetFdEntity(const char* path, int existfd = -1, bool increase_ref = true);
@ -84,7 +84,7 @@ class FdManager
bool ChangeEntityToTempPath(FdEntity* ent, const char* path); bool ChangeEntityToTempPath(FdEntity* ent, const char* path);
void CleanupCacheDir(); void CleanupCacheDir();
bool CheckAllCache(void); bool CheckAllCache();
}; };
#endif // S3FS_FDCACHE_H_ #endif // S3FS_FDCACHE_H_

View File

@ -44,8 +44,8 @@ class AutoFdEntity
AutoFdEntity(); AutoFdEntity();
~AutoFdEntity(); ~AutoFdEntity();
bool Close(void); bool Close();
bool Detach(void); bool Detach();
FdEntity* GetFdEntity(const char* path, int existfd = -1, bool increase_ref = true); FdEntity* GetFdEntity(const char* path, int existfd = -1, bool increase_ref = true);
FdEntity* Open(const char* path, headers_t* pmeta = NULL, off_t size = -1, time_t time = -1, bool force_tmpfile = false, bool is_create = true, bool no_fd_lock_wait = false); FdEntity* Open(const char* path, headers_t* pmeta = NULL, off_t size = -1, time_t time = -1, bool force_tmpfile = false, bool is_create = true, bool no_fd_lock_wait = false);
FdEntity* ExistOpen(const char* path, int existfd = -1, bool ignore_existfd = false); FdEntity* ExistOpen(const char* path, int existfd = -1, bool ignore_existfd = false);

View File

@ -622,7 +622,7 @@ bool FdEntity::RenamePath(const std::string& newpath, std::string& fentmapkey)
return true; return true;
} }
bool FdEntity::IsModified(void) const bool FdEntity::IsModified() const
{ {
AutoLock auto_data_lock(const_cast<pthread_mutex_t *>(&fdent_data_lock)); AutoLock auto_data_lock(const_cast<pthread_mutex_t *>(&fdent_data_lock));
return pagelist.IsModified(); return pagelist.IsModified();

View File

@ -56,37 +56,37 @@ class FdEntity
static int FillFile(int fd, unsigned char byte, off_t size, off_t start); static int FillFile(int fd, unsigned char byte, off_t size, off_t start);
static ino_t GetInode(int fd); static ino_t GetInode(int fd);
void Clear(void); void Clear();
ino_t GetInode(void); ino_t GetInode();
int OpenMirrorFile(void); int OpenMirrorFile();
bool SetAllStatus(bool is_loaded); // [NOTE] not locking bool SetAllStatus(bool is_loaded); // [NOTE] not locking
bool SetAllStatusUnloaded(void) { return SetAllStatus(false); } bool SetAllStatusUnloaded() { return SetAllStatus(false); }
int UploadPendingMeta(void); int UploadPendingMeta();
public: public:
static bool SetNoMixMultipart(void); static bool SetNoMixMultipart();
explicit FdEntity(const char* tpath = NULL, const char* cpath = NULL); explicit FdEntity(const char* tpath = NULL, const char* cpath = NULL);
~FdEntity(); ~FdEntity();
void Close(void); void Close();
bool IsOpen(void) const { return (-1 != fd); } bool IsOpen() const { return (-1 != fd); }
int Open(headers_t* pmeta = NULL, off_t size = -1, time_t time = -1, bool no_fd_lock_wait = false); int Open(headers_t* pmeta = NULL, off_t size = -1, time_t time = -1, bool no_fd_lock_wait = false);
bool OpenAndLoadAll(headers_t* pmeta = NULL, off_t* size = NULL, bool force_load = false); bool OpenAndLoadAll(headers_t* pmeta = NULL, off_t* size = NULL, bool force_load = false);
int Dup(bool lock_already_held = false); int Dup(bool lock_already_held = false);
int GetRefCnt(void) const { return refcnt; } // [NOTE] Use only debugging int GetRefCnt() const { return refcnt; } // [NOTE] Use only debugging
const char* GetPath(void) const { return path.c_str(); } const char* GetPath() const { return path.c_str(); }
bool RenamePath(const std::string& newpath, std::string& fentmapkey); bool RenamePath(const std::string& newpath, std::string& fentmapkey);
int GetFd(void) const { return fd; } int GetFd() const { return fd; }
bool IsModified(void) const; bool IsModified() const;
bool MergeOrgMeta(headers_t& updatemeta); bool MergeOrgMeta(headers_t& updatemeta);
bool GetStats(struct stat& st, bool lock_already_held = false); bool GetStats(struct stat& st, bool lock_already_held = false);
int SetCtime(time_t time, bool lock_already_held = false); int SetCtime(time_t time, bool lock_already_held = false);
int SetMtime(time_t time, bool lock_already_held = false); int SetMtime(time_t time, bool lock_already_held = false);
bool UpdateCtime(void); bool UpdateCtime();
bool UpdateMtime(void); bool UpdateMtime();
bool GetSize(off_t& size); bool GetSize(off_t& size);
bool GetXattr(std::string& xattr); bool GetXattr(std::string& xattr);
bool SetXattr(const std::string& xattr); bool SetXattr(const std::string& xattr);
@ -97,9 +97,9 @@ class FdEntity
int Load(off_t start = 0, off_t size = 0, bool lock_already_held = false, bool is_modified_flag = false); // size=0 means loading to end int Load(off_t start = 0, off_t size = 0, bool lock_already_held = false, bool is_modified_flag = false); // size=0 means loading to end
int NoCacheLoadAndPost(off_t start = 0, off_t size = 0); // size=0 means loading to end int NoCacheLoadAndPost(off_t start = 0, off_t size = 0); // size=0 means loading to end
int NoCachePreMultipartPost(void); int NoCachePreMultipartPost();
int NoCacheMultipartPost(int tgfd, off_t start, off_t size); int NoCacheMultipartPost(int tgfd, off_t start, off_t size);
int NoCacheCompleteMultipartPost(void); int NoCacheCompleteMultipartPost();
int RowFlush(const char* tpath, bool force_sync = false); int RowFlush(const char* tpath, bool force_sync = false);
int Flush(bool force_sync = false) { return RowFlush(NULL, force_sync); } int Flush(bool force_sync = false) { return RowFlush(NULL, force_sync); }

View File

@ -51,11 +51,11 @@ struct fdpage
fdpage(off_t start = 0, off_t size = 0, bool is_loaded = false, bool is_modified = false) : fdpage(off_t start = 0, off_t size = 0, bool is_loaded = false, bool is_modified = false) :
offset(start), bytes(size), loaded(is_loaded), modified(is_modified) {} offset(start), bytes(size), loaded(is_loaded), modified(is_modified) {}
off_t next(void) const off_t next() const
{ {
return (offset + bytes); return (offset + bytes);
} }
off_t end(void) const off_t end() const
{ {
return (0 < bytes ? offset + bytes - 1 : 0); return (0 < bytes ? offset + bytes - 1 : 0);
} }
@ -88,7 +88,7 @@ class PageList
static bool CheckZeroAreaInFile(int fd, off_t start, size_t bytes); static bool CheckZeroAreaInFile(int fd, off_t start, size_t bytes);
static bool CheckAreaInSparseFile(const struct fdpage& checkpage, const fdpage_list_t& sparse_list, int fd, fdpage_list_t& err_area_list, fdpage_list_t& warn_area_list); static bool CheckAreaInSparseFile(const struct fdpage& checkpage, const fdpage_list_t& sparse_list, int fd, fdpage_list_t& err_area_list, fdpage_list_t& warn_area_list);
void Clear(void); void Clear();
bool Compress(); bool Compress();
bool Parse(off_t new_pos); bool Parse(off_t new_pos);
@ -100,7 +100,7 @@ class PageList
~PageList(); ~PageList();
bool Init(off_t size, bool is_loaded, bool is_modified); bool Init(off_t size, bool is_loaded, bool is_modified);
off_t Size(void) const; off_t Size() const;
bool Resize(off_t size, bool is_loaded, bool is_modified); bool Resize(off_t size, bool is_loaded, bool is_modified);
bool IsPageLoaded(off_t start = 0, off_t size = 0) const; // size=0 is checking to end of list bool IsPageLoaded(off_t start = 0, off_t size = 0) const; // size=0 is checking to end of list
@ -110,11 +110,11 @@ class PageList
int GetUnloadedPages(fdpage_list_t& unloaded_list, off_t start = 0, off_t size = 0) const; // size=0 is checking to end of list int GetUnloadedPages(fdpage_list_t& unloaded_list, off_t start = 0, off_t size = 0) const; // size=0 is checking to end of list
bool GetPageListsForMultipartUpload(fdpage_list_t& dlpages, fdpage_list_t& mixuppages, off_t max_partsize); bool GetPageListsForMultipartUpload(fdpage_list_t& dlpages, fdpage_list_t& mixuppages, off_t max_partsize);
bool IsModified(void) const; bool IsModified() const;
bool ClearAllModified(void); bool ClearAllModified();
bool Serialize(CacheFileStat& file, bool is_output, ino_t inode); bool Serialize(CacheFileStat& file, bool is_output, ino_t inode);
void Dump(void) const; void Dump() const;
bool CompareSparseFile(int fd, size_t file_size, fdpage_list_t& err_area_list, fdpage_list_t& warn_area_list); bool CompareSparseFile(int fd, size_t file_size, fdpage_list_t& err_area_list, fdpage_list_t& warn_area_list);
}; };

View File

@ -36,7 +36,7 @@
//------------------------------------------------ //------------------------------------------------
std::string CacheFileStat::GetCacheFileStatTopDir() std::string CacheFileStat::GetCacheFileStatTopDir()
{ {
std::string top_path(""); std::string top_path;
if(!FdManager::IsCacheDir() || bucket.empty()){ if(!FdManager::IsCacheDir() || bucket.empty()){
return top_path; return top_path;
} }

View File

@ -36,20 +36,20 @@ class CacheFileStat
bool RawOpen(bool readonly); bool RawOpen(bool readonly);
public: public:
static std::string GetCacheFileStatTopDir(void); static std::string GetCacheFileStatTopDir();
static bool DeleteCacheFileStat(const char* path); static bool DeleteCacheFileStat(const char* path);
static bool CheckCacheFileStatTopDir(void); static bool CheckCacheFileStatTopDir();
static bool DeleteCacheFileStatDirectory(void); static bool DeleteCacheFileStatDirectory();
static bool RenameCacheFileStat(const char* oldpath, const char* newpath); static bool RenameCacheFileStat(const char* oldpath, const char* newpath);
explicit CacheFileStat(const char* tpath = NULL); explicit CacheFileStat(const char* tpath = NULL);
~CacheFileStat(); ~CacheFileStat();
bool Open(void); bool Open();
bool ReadOnlyOpen(void); bool ReadOnlyOpen();
bool Release(void); bool Release();
bool SetPath(const char* tpath, bool is_open = true); bool SetPath(const char* tpath, bool is_open = true);
int GetFd(void) const { return fd; } int GetFd() const { return fd; }
}; };
#endif // S3FS_FDCACHE_STAT_H_ #endif // S3FS_FDCACHE_STAT_H_

View File

@ -36,17 +36,17 @@ std::string s3fs_sha256_hex_fd(int fd, off_t start, off_t size);
// //
// in xxxxxx_auth.cpp // in xxxxxx_auth.cpp
// //
const char* s3fs_crypt_lib_name(void); const char* s3fs_crypt_lib_name();
bool s3fs_init_global_ssl(void); bool s3fs_init_global_ssl();
bool s3fs_destroy_global_ssl(void); bool s3fs_destroy_global_ssl();
bool s3fs_init_crypt_mutex(void); bool s3fs_init_crypt_mutex();
bool s3fs_destroy_crypt_mutex(void); bool s3fs_destroy_crypt_mutex();
bool s3fs_HMAC(const void* key, size_t keylen, const unsigned char* data, size_t datalen, unsigned char** digest, unsigned int* digestlen); bool s3fs_HMAC(const void* key, size_t keylen, const unsigned char* data, size_t datalen, unsigned char** digest, unsigned int* digestlen);
bool s3fs_HMAC256(const void* key, size_t keylen, const unsigned char* data, size_t datalen, unsigned char** digest, unsigned int* digestlen); bool s3fs_HMAC256(const void* key, size_t keylen, const unsigned char* data, size_t datalen, unsigned char** digest, unsigned int* digestlen);
size_t get_md5_digest_length(void); size_t get_md5_digest_length();
unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size); unsigned char* s3fs_md5_fd(int fd, off_t start, off_t size);
bool s3fs_sha256(const unsigned char* data, unsigned int datalen, unsigned char** digest, unsigned int* digestlen); bool s3fs_sha256(const unsigned char* data, unsigned int datalen, unsigned char** digest, unsigned int* digestlen);
size_t get_sha256_digest_length(void); size_t get_sha256_digest_length();
unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size); unsigned char* s3fs_sha256_fd(int fd, off_t start, off_t size);
#endif // S3FS_AUTH_H_ #endif // S3FS_AUTH_H_

View File

@ -24,9 +24,9 @@
//------------------------------------------------------------------- //-------------------------------------------------------------------
// Functions // Functions
//------------------------------------------------------------------- //-------------------------------------------------------------------
void show_usage(void); void show_usage();
void show_help(void); void show_help();
void show_version(void); void show_version();
#endif // S3FS_S3FS_HELP_H_ #endif // S3FS_S3FS_HELP_H_

View File

@ -48,14 +48,14 @@ class S3ObjList
bool insert_normalized(const char* name, const char* normalized, bool is_dir); bool insert_normalized(const char* name, const char* normalized, bool is_dir);
const s3obj_entry* GetS3Obj(const char* name) const; const s3obj_entry* GetS3Obj(const char* name) const;
s3obj_t::const_iterator begin(void) const { return objects.begin(); } s3obj_t::const_iterator begin() const { return objects.begin(); }
s3obj_t::const_iterator end(void) const { return objects.end(); } s3obj_t::const_iterator end() const { return objects.end(); }
public: public:
S3ObjList() {} S3ObjList() {}
~S3ObjList() {} ~S3ObjList() {}
bool IsEmpty(void) const { return objects.empty(); } bool IsEmpty() const { return objects.empty(); }
bool insert(const char* name, const char* etag = NULL, bool is_dir = false); bool insert(const char* name, const char* etag = NULL, bool is_dir = false);
std::string GetOrgName(const char* name) const; std::string GetOrgName(const char* name) const;
std::string GetNormalizedName(const char* name) const; std::string GetNormalizedName(const char* name) const;

View File

@ -47,9 +47,8 @@ bool S3fsSignals::Initialize()
bool S3fsSignals::Destroy() bool S3fsSignals::Destroy()
{ {
if(S3fsSignals::pSingleton){
delete S3fsSignals::pSingleton; delete S3fsSignals::pSingleton;
} S3fsSignals::pSingleton = NULL;
return true; return true;
} }

View File

@ -36,29 +36,29 @@ class S3fsSignals
Semaphore* pSemUsr1; Semaphore* pSemUsr1;
protected: protected:
static S3fsSignals* get(void) { return pSingleton; } static S3fsSignals* get() { return pSingleton; }
static void HandlerUSR1(int sig); static void HandlerUSR1(int sig);
static void* CheckCacheWorker(void* arg); static void* CheckCacheWorker(void* arg);
static void HandlerUSR2(int sig); static void HandlerUSR2(int sig);
static bool InitUsr2Handler(void); static bool InitUsr2Handler();
S3fsSignals(); S3fsSignals();
~S3fsSignals(); ~S3fsSignals();
bool InitUsr1Handler(void); bool InitUsr1Handler();
bool DestroyUsr1Handler(void); bool DestroyUsr1Handler();
bool WakeupUsr1Thread(void); bool WakeupUsr1Thread();
public: public:
static bool Initialize(void); static bool Initialize();
static bool Destroy(void); static bool Destroy();
static bool SetUsr1Handler(const char* path); static bool SetUsr1Handler(const char* path);
static s3fs_log_level SetLogLevel(s3fs_log_level level); static s3fs_log_level SetLogLevel(s3fs_log_level level);
static s3fs_log_level BumpupLogLevel(void); static s3fs_log_level BumpupLogLevel();
}; };
#endif // S3FS_SIGHANDLERS_H_ #endif // S3FS_SIGHANDLERS_H_

View File

@ -72,7 +72,7 @@ std::string lower(std::string s);
// //
// Date string // Date string
// //
std::string get_date_rfc850(void); std::string get_date_rfc850();
void get_date_sigv3(std::string& date, std::string& date8601); void get_date_sigv3(std::string& date, std::string& date8601);
std::string get_date_string(time_t tm); std::string get_date_string(time_t tm);
std::string get_date_iso8601(time_t tm); std::string get_date_iso8601(time_t tm);

View File

@ -258,7 +258,7 @@ struct filepart
clear(); clear();
} }
void clear(void) void clear()
{ {
uploaded = false; uploaded = false;
etag = ""; etag = "";