Fixed errors reported by cppcheck 2.13.0

This commit is contained in:
Takeshi Nakatani 2024-01-24 13:46:55 +00:00
parent 2f9fb74a42
commit 03e216006c
8 changed files with 14 additions and 14 deletions

View File

@ -431,7 +431,7 @@ bool FdManager::HasOpenEntityFd(const char* path)
{
AutoLock auto_lock(&FdManager::fd_manager_lock);
FdEntity* ent;
const FdEntity* ent;
int fd = -1;
if(nullptr == (ent = FdManager::singleton.GetFdEntity(path, fd, false, AutoLock::ALREADY_LOCKED))){
return false;
@ -916,7 +916,7 @@ bool FdManager::RawCheckAllCache(FILE* fp, const char* cache_stat_top_dir, const
}
// loop in directory of cache file's stats
struct dirent* pdirent = nullptr;
const struct dirent* pdirent = nullptr;
while(nullptr != (pdirent = readdir(statsdir))){
if(DT_DIR == pdirent->d_type){
// found directory

View File

@ -683,7 +683,7 @@ bool PseudoFdInfo::CancelAllThreads()
// [NOTE]
// Maximum multipart upload size must be uploading boundary.
//
bool PseudoFdInfo::ExtractUploadPartsFromUntreatedArea(off_t& untreated_start, off_t& untreated_size, mp_part_list_t& to_upload_list, filepart_list_t& cancel_upload_list, off_t max_mp_size)
bool PseudoFdInfo::ExtractUploadPartsFromUntreatedArea(const off_t& untreated_start, const off_t& untreated_size, mp_part_list_t& to_upload_list, filepart_list_t& cancel_upload_list, off_t max_mp_size)
{
if(untreated_start < 0 || untreated_size <= 0){
S3FS_PRN_ERR("Paramters are wrong(untreated_start=%lld, untreated_size=%lld).", static_cast<long long int>(untreated_start), static_cast<long long int>(untreated_size));

View File

@ -86,7 +86,7 @@ class PseudoFdInfo
bool ParallelMultipartUpload(const char* path, const mp_part_list_t& mplist, bool is_copy, AutoLock::Type type = AutoLock::NONE);
bool InsertUploadPart(off_t start, off_t size, int part_num, bool is_copy, etagpair** ppetag, AutoLock::Type type = AutoLock::NONE);
bool CancelAllThreads();
bool ExtractUploadPartsFromUntreatedArea(off_t& untreated_start, off_t& untreated_size, mp_part_list_t& to_upload_list, filepart_list_t& cancel_upload_list, off_t max_mp_size);
bool ExtractUploadPartsFromUntreatedArea(const off_t& untreated_start, const off_t& untreated_size, mp_part_list_t& to_upload_list, filepart_list_t& cancel_upload_list, off_t max_mp_size);
public:
explicit PseudoFdInfo(int fd = -1, int open_flags = 0);

View File

@ -820,7 +820,7 @@ static int check_object_owner(const char* path, struct stat* pstbuf)
int result;
struct stat st;
struct stat* pst = (pstbuf ? pstbuf : &st);
struct fuse_context* pcxt;
const struct fuse_context* pcxt;
S3FS_PRN_DBG("[path=%s]", path);
@ -1019,7 +1019,7 @@ static int s3fs_getattr(const char* _path, struct stat* stbuf)
// (See: Issue 241)
if(stbuf){
AutoFdEntity autoent;
FdEntity* ent;
const FdEntity* ent;
if(nullptr != (ent = autoent.OpenExistFdEntity(path))){
struct stat tmpstbuf;
if(ent->GetStats(tmpstbuf)){
@ -1151,7 +1151,7 @@ static int s3fs_create(const char* _path, mode_t mode, struct fuse_file_info* fi
{
WTF8_ENCODE(path)
int result;
struct fuse_context* pcxt;
const struct fuse_context* pcxt;
FUSE_CTX_INFO("[path=%s][mode=%04o][flags=0x%x]", path, mode, fi->flags);
@ -1405,7 +1405,7 @@ static int s3fs_symlink(const char* _from, const char* _to)
WTF8_ENCODE(from)
WTF8_ENCODE(to)
int result;
struct fuse_context* pcxt;
const struct fuse_context* pcxt;
FUSE_CTX_INFO("[from=%s][to=%s]", from, to);
@ -2783,7 +2783,7 @@ static int s3fs_truncate(const char* _path, off_t size)
}else{
// Not found -> Make tmpfile(with size)
struct fuse_context* pcxt;
const struct fuse_context* pcxt;
if(nullptr == (pcxt = fuse_get_context())){
return -EIO;
}
@ -4770,7 +4770,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
}
if(!nonempty){
struct dirent *ent;
const struct dirent *ent;
DIR *dp = opendir(mountpoint.c_str());
if(dp == nullptr){
S3FS_PRN_EXIT("failed to open MOUNTPOINT: %s: %s", mountpoint.c_str(), strerror(errno));

View File

@ -400,7 +400,7 @@ bool compare_sysname(const char* target)
// The buffer size of sysname member in struct utsname is
// OS dependent, but 512 bytes is sufficient for now.
//
static char* psysname = nullptr;
static const char* psysname = nullptr;
static char sysname[512];
if(!psysname){
struct utsname sysinfo;

View File

@ -124,7 +124,7 @@ std::string trim(std::string s, const char *t /* = SPACES */)
return trim_left(trim_right(std::move(s), t), t);
}
std::string peeloff(std::string s)
std::string peeloff(const std::string& s)
{
if(s.size() < 2 || *s.begin() != '"' || *s.rbegin() != '"'){
return s;

View File

@ -79,7 +79,7 @@ std::string trim_left(std::string s, const char *t = SPACES);
std::string trim_right(std::string s, const char *t = SPACES);
std::string trim(std::string s, const char *t = SPACES);
std::string lower(std::string s);
std::string peeloff(std::string s);
std::string peeloff(const std::string& s);
//
// Date string

View File

@ -54,7 +54,7 @@ const std::string& S3fsCred::GetBucket()
#define ASSERT_IS_SORTED(x) assert_is_sorted((x), __FILE__, __LINE__)
void assert_is_sorted(struct curl_slist* list, const char *file, int line)
void assert_is_sorted(const struct curl_slist* list, const char *file, int line)
{
for(; list != nullptr; list = list->next){
std::string key1 = list->data;