Skip to content

Commit

Permalink
Fixed errors reported by cppcheck 2.13.0 (s3fs-fuse#2400)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggtakec authored Jan 24, 2024
1 parent 2f9fb74 commit 54aa278
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/fdcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/fdcache_fdinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/fdcache_fdinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)){
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/s3fs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/string_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test_curl_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 54aa278

Please sign in to comment.