Merge pull request #1074 from gaul/clang-tidy

Configure clang-tidy target
This commit is contained in:
Takeshi Nakatani 2019-07-07 15:28:08 +09:00 committed by GitHub
commit 6bd1a7eac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 16 deletions

View File

@ -1,6 +1,7 @@
Checks: '
-*,
bugprone-*,
-bugprone-macro-parentheses,
google-*,
-google-build-using-namespace,
-google-readability-casting,
@ -12,6 +13,7 @@ Checks: '
-misc-redundant-expression,
-misc-unused-parameters,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-deprecated-headers,
-modernize-loop-convert,
-modernize-use-auto,
@ -22,5 +24,7 @@ Checks: '
readability-*,
-readability-else-after-return,
-readability-implicit-bool-conversion,
-readability-isolate-declaration,
-readability-magic-numbers,
-readability-named-parameter,
-readability-simplify-boolean-expr'

View File

@ -24,7 +24,15 @@ if USE_GNUTLS_NETTLE
AM_CPPFLAGS += -DUSE_GNUTLS_NETTLE
endif
s3fs_SOURCES = s3fs.cpp s3fs.h curl.cpp curl.h cache.cpp cache.h string_util.cpp string_util.h s3fs_util.cpp s3fs_util.h fdcache.cpp fdcache.h common_auth.cpp s3fs_auth.h addhead.cpp addhead.h common.h
s3fs_SOURCES = \
s3fs.cpp \
curl.cpp \
cache.cpp \
string_util.cpp \
s3fs_util.cpp \
fdcache.cpp \
common_auth.cpp \
addhead.cpp
if USE_SSL_OPENSSL
s3fs_SOURCES += openssl_auth.cpp
endif
@ -39,6 +47,9 @@ s3fs_LDADD = $(DEPS_LIBS)
noinst_PROGRAMS = test_string_util
test_string_util_SOURCES = string_util.cpp test_string_util.cpp test_util.h
test_string_util_SOURCES = string_util.cpp test_string_util.cpp
TESTS = test_string_util
clang-tidy:
clang-tidy $(s3fs_SOURCES) -- $(DEPS_CFLAGS) $(CPPFLAGS)

View File

@ -3853,7 +3853,7 @@ int S3fsCurl::MultipartHeadRequest(const char* tpath, off_t size, headers_t& met
strrange.str("");
strrange.clear(stringstream::goodbit);
if(0 != (result = CopyMultipartPostSetup(tpath, tpath, (list.size() + 1), upload_id, meta))){
if(0 != (result = CopyMultipartPostSetup(tpath, tpath, static_cast<int>(list.size() + 1), upload_id, meta))){
return result;
}
list.push_back(partdata.etag);

View File

@ -937,7 +937,7 @@ static int s3fs_readlink(const char* _path, char* buf, size_t size)
if(use_wtf8){
strTmp = s3fs_wtf8_decode(strTmp);
}
strcpy(buf, strTmp.c_str());
strncpy(buf, strTmp.c_str(), size);
FdManager::get()->Close(ent);
S3FS_MALLOCTRIM(0);
@ -973,7 +973,7 @@ static int do_create_bucket()
headers_t meta;
S3fsCurl s3fscurl(true);
long res = s3fscurl.PutRequest("/", meta, tmpfd);
int res = s3fscurl.PutRequest("/", meta, tmpfd);
if(res < 0){
long responseCode = s3fscurl.GetLastResponseCode();
if((responseCode == 400 || responseCode == 403) && S3fsCurl::IsSignatureV4()){
@ -4558,7 +4558,7 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
return 0;
}
if(0 == STR2NCMP(arg, "multireq_max=")){
long maxreq = static_cast<long>(s3fs_strtoofft(strchr(arg, '=') + sizeof(char)));
int maxreq = static_cast<int>(s3fs_strtoofft(strchr(arg, '=') + sizeof(char)));
S3fsCurl::SetMaxMultiRequest(maxreq);
return 0;
}

View File

@ -96,7 +96,7 @@ off_t s3fs_strtoofft(const char* str, bool is_base_16)
string lower(string s)
{
// change each character of the string to lower case
for(unsigned int i = 0; i < s.length(); i++){
for(size_t i = 0; i < s.length(); i++){
s[i] = tolower(s[i]);
}
return s;
@ -132,7 +132,7 @@ string trim(const string &s, const string &t /* = SPACES */)
string urlEncode(const string &s)
{
string result;
for (unsigned i = 0; i < s.length(); ++i) {
for (size_t i = 0; i < s.length(); ++i) {
char c = s[i];
if (c == '/' // Note- special case for fuse paths...
|| c == '.'
@ -160,7 +160,7 @@ string urlEncode(const string &s)
string urlEncode2(const string &s)
{
string result;
for (unsigned i = 0; i < s.length(); ++i) {
for (size_t i = 0; i < s.length(); ++i) {
char c = s[i];
if (c == '=' // Note- special case for fuse paths...
|| c == '&' // Note- special case for s3...
@ -185,11 +185,11 @@ string urlEncode2(const string &s)
string urlDecode(const string& s)
{
string result;
for(unsigned i = 0; i < s.length(); ++i){
for(size_t i = 0; i < s.length(); ++i){
if(s[i] != '%'){
result += s[i];
}else{
char ch = 0;
int ch = 0;
if(s.length() <= ++i){
break; // wrong format.
}
@ -199,7 +199,7 @@ string urlDecode(const string& s)
}
ch *= 16;
ch += ('0' <= s[i] && s[i] <= '9') ? (s[i] - '0') : ('A' <= s[i] && s[i] <= 'F') ? (s[i] - 'A' + 0x0a) : ('a' <= s[i] && s[i] <= 'f') ? (s[i] - 'a' + 0x0a) : 0x00;
result += ch;
result += static_cast<char>(ch);
}
}
return result;
@ -525,9 +525,9 @@ bool s3fs_wtf8_encode(const char *s, string *result)
invalid = true;
if (result) {
unsigned escape = escape_base + c;
*result += 0xe0 | ((escape >> 12) & 0x0f);
*result += 0x80 | ((escape >> 06) & 0x3f);
*result += 0x80 | ((escape >> 00) & 0x3f);
*result += static_cast<char>(0xe0 | ((escape >> 12) & 0x0f));
*result += static_cast<char>(0x80 | ((escape >> 06) & 0x3f));
*result += static_cast<char>(0x80 | ((escape >> 00) & 0x3f));
}
}
return invalid;
@ -556,7 +556,7 @@ bool s3fs_wtf8_decode(const char *s, string *result)
// convert back
encoded = true;
if(result){
*result += code - escape_base;
*result += static_cast<char>(code - escape_base);
}
s+=2;
continue;