diff --git a/src/addhead.cpp b/src/addhead.cpp index 0b7147b..e3157eb 100644 --- a/src/addhead.cpp +++ b/src/addhead.cpp @@ -168,7 +168,7 @@ void AdditionalHeader::Unload() { is_enable = false; - for(addheadlist_t::iterator iter = addheadlist.begin(); iter != addheadlist.end(); iter = addheadlist.erase(iter)){ + for(addheadlist_t::iterator iter = addheadlist.begin(); iter != addheadlist.end(); ++iter){ ADDHEAD *paddhead = *iter; if(paddhead){ if(paddhead->pregex){ @@ -178,6 +178,7 @@ void AdditionalHeader::Unload() delete paddhead; } } + addheadlist.clear(); } bool AdditionalHeader::AddHeader(headers_t& meta, const char* path) const diff --git a/src/cache.cpp b/src/cache.cpp index 727aac7..6bb7a70 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -87,7 +87,7 @@ inline void InitStatCacheTime(struct timespec& ts) ts.tv_nsec = 0; } -inline int CompareStatCacheTime(struct timespec& ts1, struct timespec& ts2) +inline int CompareStatCacheTime(const struct timespec& ts1, const struct timespec& ts2) { // return -1: ts1 < ts2 // 0: ts1 == ts2 @@ -304,7 +304,7 @@ bool StatCache::GetStat(const string& key, struct stat* pst, headers_t* meta, bo return false; } -bool StatCache::IsNoObjectCache(string& key, bool overcheck) +bool StatCache::IsNoObjectCache(const string& key, bool overcheck) { bool is_delete_cache = false; string strpath = key; diff --git a/src/cache.h b/src/cache.h index 6472685..f210080 100644 --- a/src/cache.h +++ b/src/cache.h @@ -110,7 +110,7 @@ class StatCache } // Cache For no object - bool IsNoObjectCache(std::string& key, bool overcheck = true); + bool IsNoObjectCache(const std::string& key, bool overcheck = true); bool AddNoObjectCache(std::string& key); // Add stat cache diff --git a/src/curl.cpp b/src/curl.cpp index c6bdeda..24527dd 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -3420,7 +3420,7 @@ int S3fsCurl::PreMultipartPostRequest(const char* tpath, headers_t& meta, string return 0; } -int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, string& upload_id, etaglist_t& parts) +int S3fsCurl::CompleteMultipartPostRequest(const char* tpath, const string& upload_id, etaglist_t& parts) { S3FS_PRN_INFO3("[tpath=%s][parts=%zu]", SAFESTRPTR(tpath), parts.size()); @@ -3530,7 +3530,7 @@ int S3fsCurl::MultipartListRequest(string& body) return result; } -int S3fsCurl::AbortMultipartUpload(const char* tpath, string& upload_id) +int S3fsCurl::AbortMultipartUpload(const char* tpath, const string& upload_id) { S3FS_PRN_INFO3("[tpath=%s]", SAFESTRPTR(tpath)); @@ -3662,7 +3662,7 @@ int S3fsCurl::UploadMultipartPostRequest(const char* tpath, int part_num, const return result; } -int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_num, string& upload_id, headers_t& meta) +int S3fsCurl::CopyMultipartPostSetup(const char* from, const char* to, int part_num, const string& upload_id, headers_t& meta) { S3FS_PRN_INFO3("[from=%s][to=%s][part=%d]", SAFESTRPTR(from), SAFESTRPTR(to), part_num); diff --git a/src/curl.h b/src/curl.h index da99998..c1441d0 100644 --- a/src/curl.h +++ b/src/curl.h @@ -396,7 +396,7 @@ class S3fsCurl int GetIAMCredentials(void); int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id); - int CopyMultipartPostSetup(const char* from, const char* to, int part_num, 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); bool UploadMultipartPostComplete(); bool CopyMultipartPostComplete(); @@ -494,10 +494,10 @@ class S3fsCurl int CheckBucket(void); int ListBucketRequest(const char* tpath, const char* query); int PreMultipartPostRequest(const char* tpath, headers_t& meta, std::string& upload_id, bool is_copy); - int CompleteMultipartPostRequest(const char* tpath, std::string& upload_id, etaglist_t& parts); + int CompleteMultipartPostRequest(const char* tpath, const std::string& upload_id, etaglist_t& parts); int UploadMultipartPostRequest(const char* tpath, int part_num, const std::string& upload_id); int MultipartListRequest(std::string& body); - int AbortMultipartUpload(const char* tpath, std::string& upload_id); + int AbortMultipartUpload(const char* tpath, const std::string& upload_id); int MultipartHeadRequest(const char* tpath, off_t size, headers_t& meta, bool is_copy); int MultipartUploadRequest(const char* tpath, headers_t& meta, int fd, bool is_copy); int MultipartUploadRequest(const std::string& upload_id, const char* tpath, int fd, off_t offset, off_t size, etaglist_t& list); diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 2fcf07b..19dbc0c 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -172,7 +172,7 @@ static int check_parent_object_access(const char* path, int mask); static FdEntity* get_local_fent(const char* path, bool is_load = false); static bool multi_head_callback(S3fsCurl* s3fscurl); static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl); -static int readdir_multi_head(const char* path, S3ObjList& head, void* buf, fuse_fill_dir_t filler); +static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf, fuse_fill_dir_t filler); static int list_bucket(const char* path, S3ObjList& head, const char* delimiter, bool check_content_only = false); static int directory_empty(const char* path); static bool is_truncated(xmlDocPtr doc); @@ -2440,7 +2440,7 @@ static S3fsCurl* multi_head_retry_callback(S3fsCurl* s3fscurl) return newcurl; } -static int readdir_multi_head(const char* path, S3ObjList& head, void* buf, fuse_fill_dir_t filler) +static int readdir_multi_head(const char* path, const S3ObjList& head, void* buf, fuse_fill_dir_t filler) { S3fsMultiCurl curlmulti(S3fsCurl::GetMaxMultiRequest()); s3obj_list_t headlist; @@ -2750,7 +2750,7 @@ static bool GetXmlNsUrl(xmlDocPtr doc, string& nsurl) bool result = false; if(!doc){ - return result; + return false; } if((tmLast + 60) < time(NULL)){ // refresh @@ -2877,7 +2877,7 @@ static bool is_truncated(xmlDocPtr doc) xmlChar* strTruncate = get_base_exp(doc, "IsTruncated"); if(!strTruncate){ - return result; + return false; } if(0 == strcasecmp((const char*)strTruncate, "true")){ result = true; diff --git a/src/s3fs_util.cpp b/src/s3fs_util.cpp index 0e370b4..2a1c9f8 100644 --- a/src/s3fs_util.cpp +++ b/src/s3fs_util.cpp @@ -994,18 +994,18 @@ bool simple_parse_xml(const char* data, size_t len, const char* key, std::string bool result = false; if(!data || !key){ - return result; + return false; } value.clear(); xmlDocPtr doc; if(NULL == (doc = xmlReadMemory(data, len, "", NULL, 0))){ - return result; + return false; } if(NULL == doc->children){ S3FS_XMLFREEDOC(doc); - return result; + return false; } for(xmlNodePtr cur_node = doc->children->children; NULL != cur_node; cur_node = cur_node->next){ // For DEBUG