From cb3dc28e6eab4281c7d11f6055f4a0cb8e570c52 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Tue, 20 Jun 2023 15:18:54 +0000 Subject: [PATCH] Supported cppcheck 2.10(and changed std from c++03 to c++11 for RHEL7) --- .github/workflows/ci.yml | 6 +++--- Makefile.am | 4 ++-- configure.ac | 2 +- src/curl.cpp | 2 +- src/fdcache.cpp | 2 +- src/fdcache_page.cpp | 17 ++++++++++++----- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06f5718..8c2bb66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,7 +102,7 @@ jobs: - name: Cppcheck run: | # specify the version range to run cppcheck (cppcheck version number is x.y or x.y.z) - if cppcheck --version | sed -e 's/\./ /g' | awk '{if (($2 * 1000 + $3) <= 1086 || ($2 * 1000 + $3) >= 2010) { exit(1) } }'; then + if cppcheck --version | sed -e 's/\./ /g' | awk '{if ($2 * 1000 + $3) <= 1086) { exit(1) } }'; then make cppcheck fi @@ -160,13 +160,13 @@ jobs: - name: Build run: | ./autogen.sh - PKG_CONFIG_PATH=/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig ./configure CXXFLAGS='-std=c++03 -DS3FS_PTHREAD_ERRORCHECK=1' + PKG_CONFIG_PATH=/usr/local/opt/curl/lib/pkgconfig:/usr/local/opt/openssl/lib/pkgconfig ./configure CXXFLAGS='-std=c++11 -DS3FS_PTHREAD_ERRORCHECK=1' make --jobs=$(sysctl -n hw.ncpu) - name: Cppcheck run: | # specify the version range to run cppcheck (cppcheck version number is x.y or x.y.z) - if cppcheck --version | sed -e 's/\./ /g' | awk '{if (($2 * 1000 + $3) <= 1086 || ($2 * 1000 + $3) >= 2010) { exit(1) } }'; then + if cppcheck --version | sed -e 's/\./ /g' | awk '{if ($2 * 1000 + $3) <= 1086) { exit(1) } }'; then make cppcheck fi diff --git a/Makefile.am b/Makefile.am index 01480d3..6447320 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,7 +34,7 @@ release : dist ../utils/release.sh cppcheck: cppcheck --quiet --error-exitcode=1 \ --inline-suppr \ - --std=c++03 \ + --std=c++11 \ --xml \ -D HAVE_ATTR_XATTR_H \ -D HAVE_SYS_EXTATTR_H \ @@ -81,6 +81,6 @@ shellcheck: # tab-width: 4 # c-basic-offset: 4 # End: -# vim600: expandtab sw=4 ts= fdm=marker +# vim600: expandtab sw=4 ts=4 fdm=marker # vim<600: expandtab sw=4 ts=4 # diff --git a/configure.ac b/configure.ac index cd6303c..7391ea6 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,7 @@ AC_CHECK_HEADERS([attr/xattr.h]) AC_CHECK_HEADERS([sys/extattr.h]) AC_CHECK_FUNCS([fallocate]) -CXXFLAGS="$CXXFLAGS -Wall -fno-exceptions -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=3" +CXXFLAGS="$CXXFLAGS -Wall -fno-exceptions -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=3 -std=c++11" dnl ---------------------------------------------- dnl For macOS diff --git a/src/curl.cpp b/src/curl.cpp index 4471c18..d6bfc83 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -410,7 +410,7 @@ bool S3fsCurl::InitMimeType(const std::string& strFile) if(MT.good()){ S3FS_PRN_DBG("The old mime types are cleared to load new mime types."); S3fsCurl::mimeTypes.clear(); - std::string line; + std::string line; while(getline(MT, line)){ if(line.empty()){ diff --git a/src/fdcache.cpp b/src/fdcache.cpp index edbe527..1318392 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -415,7 +415,7 @@ int FdManager::GetOpenFdCount(const char* path) { AutoLock auto_lock(&FdManager::fd_manager_lock); - return FdManager::singleton.GetPseudoFdCount(path); + return FdManager::singleton.GetPseudoFdCount(path); } //------------------------------------------------ diff --git a/src/fdcache_page.cpp b/src/fdcache_page.cpp index 4eeff19..1dda64d 100644 --- a/src/fdcache_page.cpp +++ b/src/fdcache_page.cpp @@ -959,11 +959,18 @@ bool PageList::Serialize(CacheFileStat& file, bool is_output, ino_t inode) is_modified = (1 == cvt_strtoofft(part.c_str(), /* base= */10) ? true : false); } // add new area - PageList::page_status pstatus = - ( is_loaded && is_modified ? PageList::PAGE_LOAD_MODIFIED : - !is_loaded && is_modified ? PageList::PAGE_MODIFIED : - is_loaded && !is_modified ? PageList::PAGE_LOADED : PageList::PAGE_NOT_LOAD_MODIFIED ); - + PageList::page_status pstatus = PageList::PAGE_NOT_LOAD_MODIFIED; + if(is_loaded){ + if(is_modified){ + pstatus = PageList::PAGE_LOAD_MODIFIED; + }else{ + pstatus = PageList::PAGE_LOADED; + } + }else{ + if(is_modified){ + pstatus = PageList::PAGE_MODIFIED; + } + } SetPageLoadedStatus(offset, size, pstatus); } delete[] ptmp;