From 0cd73e406db4f349973404fb87f17cfc5d79bd81 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Sun, 12 Nov 2023 11:48:08 +0900 Subject: [PATCH] Address clang-tidy 17 warnings (#2362) --- .clang-tidy | 2 ++ src/curl.cpp | 5 ++++- src/s3fs.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 593f622..56961c9 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -36,6 +36,7 @@ Checks: ' -google-runtime-references, misc-*, -misc-const-correctness, + -misc-include-cleaner, -misc-no-recursion, -misc-redundant-expression, -misc-unused-parameters, @@ -52,6 +53,7 @@ Checks: ' -modernize-use-trailing-return-type, -modernize-use-using, performance-*, + -performance-avoid-endl, -performance-no-int-to-ptr, portability-*, readability-*, diff --git a/src/curl.cpp b/src/curl.cpp index 27221b8..846a5b2 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -2139,7 +2139,10 @@ bool S3fsCurl::RemakeHandle() // rewind file struct stat st; if(b_infile){ - rewind(b_infile); + if(-1 == fseek(b_infile, 0, SEEK_SET)){ + S3FS_PRN_WARN("Could not reset position(fd=%d)", fileno(b_infile)); + return false; + } if(-1 == fstat(fileno(b_infile), &st)){ S3FS_PRN_WARN("Could not get file stat(fd=%d)", fileno(b_infile)); return false; diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 17d4ece..9d34205 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -206,8 +206,8 @@ class MpStatFlag { private: mutable pthread_mutex_t flag_lock; - bool is_lock_init; - bool has_mp_stat; + bool is_lock_init = false; + bool has_mp_stat = false; public: MpStatFlag(); @@ -221,7 +221,7 @@ class MpStatFlag bool Set(bool flag); }; -MpStatFlag::MpStatFlag() : is_lock_init(false), has_mp_stat(false) +MpStatFlag::MpStatFlag() { pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); @@ -273,7 +273,7 @@ class SyncFiller { private: mutable pthread_mutex_t filler_lock; - bool is_lock_init; + bool is_lock_init = false; void* filler_buff; fuse_fill_dir_t filler_func; std::set filled; @@ -290,7 +290,7 @@ class SyncFiller int SufficiencyFill(const std::vector& pathlist); }; -SyncFiller::SyncFiller(void* buff, fuse_fill_dir_t filler) : is_lock_init(false), filler_buff(buff), filler_func(filler) +SyncFiller::SyncFiller(void* buff, fuse_fill_dir_t filler) : filler_buff(buff), filler_func(filler) { if(!filler_buff || !filler_func){ S3FS_PRN_CRIT("Internal error: SyncFiller constructor parameter is critical value.");