mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-22 08:48:55 +00:00
Convert some const to constexpr (#2342)
This guarantees that the function or value will resolve at compile-time.
This commit is contained in:
parent
919575f312
commit
4845831f93
@ -67,5 +67,6 @@ Checks: '
|
|||||||
-readability-isolate-declaration,
|
-readability-isolate-declaration,
|
||||||
-readability-magic-numbers,
|
-readability-magic-numbers,
|
||||||
-readability-named-parameter,
|
-readability-named-parameter,
|
||||||
|
-readability-redundant-declaration,
|
||||||
-readability-simplify-boolean-expr,
|
-readability-simplify-boolean-expr,
|
||||||
-readability-suspicious-call-argument'
|
-readability-suspicious-call-argument'
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Symbols
|
// Symbols
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
#define ADD_HEAD_REGEX "reg:"
|
static constexpr char ADD_HEAD_REGEX[] = "reg:";
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class AdditionalHeader
|
// Class AdditionalHeader
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
// Global variables
|
// Global variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// TODO: namespace these
|
// TODO: namespace these
|
||||||
static const int64_t FIVE_GB = 5LL * 1024LL * 1024LL * 1024LL;
|
static constexpr int64_t FIVE_GB = 5LL * 1024LL * 1024LL * 1024LL;
|
||||||
static const off_t MIN_MULTIPART_SIZE = 5 * 1024 * 1024;
|
static constexpr off_t MIN_MULTIPART_SIZE = 5 * 1024 * 1024;
|
||||||
|
|
||||||
extern bool foreground;
|
extern bool foreground;
|
||||||
extern bool nomultipart;
|
extern bool nomultipart;
|
||||||
|
15
src/curl.cpp
15
src/curl.cpp
@ -45,14 +45,14 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Symbols
|
// Symbols
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
static const char EMPTY_PAYLOAD_HASH[] = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
static constexpr char EMPTY_PAYLOAD_HASH[] = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
||||||
static const char EMPTY_MD5_BASE64_HASH[] = "1B2M2Y8AsgTpgAmY7PhCfg==";
|
static constexpr char EMPTY_MD5_BASE64_HASH[] = "1B2M2Y8AsgTpgAmY7PhCfg==";
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class S3fsCurl
|
// Class S3fsCurl
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
static const int MULTIPART_SIZE = 10 * 1024 * 1024;
|
static constexpr int MULTIPART_SIZE = 10 * 1024 * 1024;
|
||||||
static const int GET_OBJECT_RESPONSE_LIMIT = 1024;
|
static constexpr int GET_OBJECT_RESPONSE_LIMIT = 1024;
|
||||||
|
|
||||||
// [NOTE] about default mime.types file
|
// [NOTE] about default mime.types file
|
||||||
// If no mime.types file is specified in the mime option, s3fs
|
// If no mime.types file is specified in the mime option, s3fs
|
||||||
@ -65,8 +65,8 @@ static const int GET_OBJECT_RESPONSE_LIMIT = 1024;
|
|||||||
// If the mime.types file is not found, s3fs will exit with an
|
// If the mime.types file is not found, s3fs will exit with an
|
||||||
// error.
|
// error.
|
||||||
//
|
//
|
||||||
static const char DEFAULT_MIME_FILE[] = "/etc/mime.types";
|
static constexpr char DEFAULT_MIME_FILE[] = "/etc/mime.types";
|
||||||
static const char SPECIAL_DARWIN_MIME_FILE[] = "/etc/apache2/mime.types";
|
static constexpr char SPECIAL_DARWIN_MIME_FILE[] = "/etc/apache2/mime.types";
|
||||||
|
|
||||||
// [NOTICE]
|
// [NOTICE]
|
||||||
// This symbol is for libcurl under 7.23.0
|
// This symbol is for libcurl under 7.23.0
|
||||||
@ -83,9 +83,6 @@ static const char SPECIAL_DARWIN_MIME_FILE[] = "/etc/apache2/mime.types";
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class S3fsCurl
|
// Class S3fsCurl
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
const long S3fsCurl::S3FSCURL_RESPONSECODE_NOTSET;
|
|
||||||
const long S3fsCurl::S3FSCURL_RESPONSECODE_FATAL_ERROR;
|
|
||||||
const int S3fsCurl::S3FSCURL_PERFORM_RESULT_NOTSET;
|
|
||||||
pthread_mutex_t S3fsCurl::curl_warnings_lock;
|
pthread_mutex_t S3fsCurl::curl_warnings_lock;
|
||||||
pthread_mutex_t S3fsCurl::curl_handles_lock;
|
pthread_mutex_t S3fsCurl::curl_handles_lock;
|
||||||
S3fsCurl::callback_locks_t S3fsCurl::callback_locks;
|
S3fsCurl::callback_locks_t S3fsCurl::callback_locks;
|
||||||
|
@ -193,9 +193,9 @@ class S3fsCurl
|
|||||||
CURLcode curlCode; // handle curl return
|
CURLcode curlCode; // handle curl return
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const long S3FSCURL_RESPONSECODE_NOTSET = -1;
|
static constexpr long S3FSCURL_RESPONSECODE_NOTSET = -1;
|
||||||
static const long S3FSCURL_RESPONSECODE_FATAL_ERROR = -2;
|
static constexpr long S3FSCURL_RESPONSECODE_FATAL_ERROR = -2;
|
||||||
static const int S3FSCURL_PERFORM_RESULT_NOTSET = 1;
|
static constexpr int S3FSCURL_PERFORM_RESULT_NOTSET = 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// constructor/destructor
|
// constructor/destructor
|
||||||
|
@ -264,8 +264,8 @@ std::string url_to_host(const std::string &url)
|
|||||||
{
|
{
|
||||||
S3FS_PRN_INFO3("url is %s", url.c_str());
|
S3FS_PRN_INFO3("url is %s", url.c_str());
|
||||||
|
|
||||||
static const char HTTP[] = "http://";
|
static constexpr char HTTP[] = "http://";
|
||||||
static const char HTTPS[] = "https://";
|
static constexpr char HTTPS[] = "https://";
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
|
|
||||||
if (is_prefix(url.c_str(), HTTP)) {
|
if (is_prefix(url.c_str(), HTTP)) {
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
//
|
//
|
||||||
// The following symbols are used by FdManager::RawCheckAllCache().
|
// The following symbols are used by FdManager::RawCheckAllCache().
|
||||||
//
|
//
|
||||||
#define CACHEDBG_FMT_DIR_PROB "Directory: %s"
|
// These must be #defines due to string literal concatenation.
|
||||||
#define CACHEDBG_FMT_HEAD "---------------------------------------------------------------------------\n" \
|
#define CACHEDBG_FMT_HEAD "---------------------------------------------------------------------------\n" \
|
||||||
"Check cache file and its stats file consistency at %s\n" \
|
"Check cache file and its stats file consistency at %s\n" \
|
||||||
"---------------------------------------------------------------------------"
|
"---------------------------------------------------------------------------"
|
||||||
@ -70,7 +70,7 @@
|
|||||||
// This process may not be complete, but it is easy way can
|
// This process may not be complete, but it is easy way can
|
||||||
// be realized.
|
// be realized.
|
||||||
//
|
//
|
||||||
#define NOCACHE_PATH_PREFIX_FORM " __S3FS_UNEXISTED_PATH_%lx__ / " // important space words for simply
|
static constexpr char NOCACHE_PATH_PREFIX_FORM[] = " __S3FS_UNEXISTED_PATH_%lx__ / "; // important space words for simply
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// FdManager class variable
|
// FdManager class variable
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// Symbols
|
// Symbols
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
static const int MAX_MULTIPART_CNT = 10 * 1000; // S3 multipart max count
|
static constexpr int MAX_MULTIPART_CNT = 10 * 1000; // S3 multipart max count
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// FdEntity class variables
|
// FdEntity class variables
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// Symbols
|
// Symbols
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
static const int CHECK_CACHEFILE_PART_SIZE = 1024 * 16; // Buffer size in PageList::CheckZeroAreaInFile()
|
static constexpr int CHECK_CACHEFILE_PART_SIZE = 1024 * 16; // Buffer size in PageList::CheckZeroAreaInFile()
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// fdpage_list_t utility
|
// fdpage_list_t utility
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// The minimum pseudo fd value starts 2.
|
// The minimum pseudo fd value starts 2.
|
||||||
// This is to avoid mistakes for 0(stdout) and 1(stderr), which are usually used.
|
// This is to avoid mistakes for 0(stdout) and 1(stderr), which are usually used.
|
||||||
//
|
//
|
||||||
static const int MIN_PSEUDOFD_NUMBER = 2;
|
static constexpr int MIN_PSEUDOFD_NUMBER = 2;
|
||||||
|
|
||||||
//------------------------------------------------
|
//------------------------------------------------
|
||||||
// PseudoFdManager class methods
|
// PseudoFdManager class methods
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
const char* s3fs_crypt_lib_name(void)
|
const char* s3fs_crypt_lib_name(void)
|
||||||
{
|
{
|
||||||
static const char version[] = "GnuTLS(nettle)";
|
static constexpr char version[] = "GnuTLS(nettle)";
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ const char* s3fs_crypt_lib_name(void)
|
|||||||
|
|
||||||
const char* s3fs_crypt_lib_name()
|
const char* s3fs_crypt_lib_name()
|
||||||
{
|
{
|
||||||
static const char version[] = "GnuTLS(gcrypt)";
|
static constexpr char version[] = "GnuTLS(gcrypt)";
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "metaheader.h"
|
#include "metaheader.h"
|
||||||
#include "string_util.h"
|
#include "string_util.h"
|
||||||
|
|
||||||
static const struct timespec DEFAULT_TIMESPEC = {-1, 0};
|
static constexpr struct timespec DEFAULT_TIMESPEC = {-1, 0};
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Utility functions for convert
|
// Utility functions for convert
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
const char* s3fs_crypt_lib_name()
|
const char* s3fs_crypt_lib_name()
|
||||||
{
|
{
|
||||||
static const char version[] = "NSS";
|
static constexpr char version[] = "NSS";
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
const char* s3fs_crypt_lib_name()
|
const char* s3fs_crypt_lib_name()
|
||||||
{
|
{
|
||||||
static const char version[] = "OpenSSL";
|
static constexpr char version[] = "OpenSSL";
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
@ -5540,7 +5540,7 @@ int main(int argc, char* argv[])
|
|||||||
time_t incomp_abort_time = (24 * 60 * 60);
|
time_t incomp_abort_time = (24 * 60 * 60);
|
||||||
S3fsLog singletonLog;
|
S3fsLog singletonLog;
|
||||||
|
|
||||||
static const struct option long_opts[] = {
|
static constexpr struct option long_opts[] = {
|
||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"version", no_argument, nullptr, 0},
|
{"version", no_argument, nullptr, 0},
|
||||||
{"debug", no_argument, nullptr, 'd'},
|
{"debug", no_argument, nullptr, 'd'},
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Symbols
|
// Symbols
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
#define DEFAULT_AWS_PROFILE_NAME "default"
|
static constexpr char DEFAULT_AWS_PROFILE_NAME[] = "default";
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// External Credential dummy function
|
// External Credential dummy function
|
||||||
@ -53,8 +53,8 @@
|
|||||||
//
|
//
|
||||||
const char* VersionS3fsCredential(bool detail)
|
const char* VersionS3fsCredential(bool detail)
|
||||||
{
|
{
|
||||||
static const char version[] = "built-in";
|
static constexpr char version[] = "built-in";
|
||||||
static const char detail_version[] =
|
static constexpr char detail_version[] =
|
||||||
"s3fs-fuse built-in Credential I/F Function\n"
|
"s3fs-fuse built-in Credential I/F Function\n"
|
||||||
"Copyright(C) 2007 s3fs-fuse\n";
|
"Copyright(C) 2007 s3fs-fuse\n";
|
||||||
|
|
||||||
@ -113,21 +113,19 @@ bool UpdateS3fsCredential(char** ppaccess_key_id, char** ppserect_access_key, ch
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Class Variables
|
// Class Variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
const char* S3fsCred::ALLBUCKET_FIELDS_TYPE = "";
|
constexpr char S3fsCred::ALLBUCKET_FIELDS_TYPE[];
|
||||||
const char* S3fsCred::KEYVAL_FIELDS_TYPE = "\t";
|
constexpr char S3fsCred::KEYVAL_FIELDS_TYPE[];
|
||||||
const char* S3fsCred::AWS_ACCESSKEYID = "AWSAccessKeyId";
|
constexpr char S3fsCred::AWS_ACCESSKEYID[];
|
||||||
const char* S3fsCred::AWS_SECRETKEY = "AWSSecretKey";
|
constexpr char S3fsCred::AWS_SECRETKEY[];
|
||||||
|
|
||||||
const int S3fsCred::IAM_EXPIRE_MERGIN = 20 * 60; // update timing
|
constexpr char S3fsCred::ECS_IAM_ENV_VAR[];
|
||||||
const char* S3fsCred::ECS_IAM_ENV_VAR = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
constexpr char S3fsCred::IAMCRED_ACCESSKEYID[];
|
||||||
const char* S3fsCred::IAMCRED_ACCESSKEYID = "AccessKeyId";
|
constexpr char S3fsCred::IAMCRED_SECRETACCESSKEY[];
|
||||||
const char* S3fsCred::IAMCRED_SECRETACCESSKEY = "SecretAccessKey";
|
constexpr char S3fsCred::IAMCRED_ROLEARN[];
|
||||||
const char* S3fsCred::IAMCRED_ROLEARN = "RoleArn";
|
|
||||||
|
|
||||||
const char* S3fsCred::IAMv2_token_url = "http://169.254.169.254/latest/api/token";
|
constexpr char S3fsCred::IAMv2_token_url[];
|
||||||
int S3fsCred::IAMv2_token_ttl = 21600;
|
constexpr char S3fsCred::IAMv2_token_ttl_hdr[];
|
||||||
const char* S3fsCred::IAMv2_token_ttl_hdr = "X-aws-ec2-metadata-token-ttl-seconds";
|
constexpr char S3fsCred::IAMv2_token_hdr[];
|
||||||
const char* S3fsCred::IAMv2_token_hdr = "X-aws-ec2-metadata-token";
|
|
||||||
|
|
||||||
std::string S3fsCred::bucket_name;
|
std::string S3fsCred::bucket_name;
|
||||||
|
|
||||||
@ -1186,7 +1184,7 @@ bool S3fsCred::CheckIAMCredentialUpdate(std::string* access_key_id, std::string*
|
|||||||
|
|
||||||
const char* S3fsCred::GetCredFuncVersion(bool detail) const
|
const char* S3fsCred::GetCredFuncVersion(bool detail) const
|
||||||
{
|
{
|
||||||
static const char errVersion[] = "unknown";
|
static constexpr char errVersion[] = "unknown";
|
||||||
|
|
||||||
if(!pFuncCredVersion){
|
if(!pFuncCredVersion){
|
||||||
return errVersion;
|
return errVersion;
|
||||||
|
@ -40,16 +40,16 @@ typedef std::map<std::string, std::string> iamcredmap_t;
|
|||||||
class S3fsCred
|
class S3fsCred
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const char* ALLBUCKET_FIELDS_TYPE; // special key for mapping(This name is absolutely not used as a bucket name)
|
static constexpr char ALLBUCKET_FIELDS_TYPE[] = ""; // special key for mapping(This name is absolutely not used as a bucket name)
|
||||||
static const char* KEYVAL_FIELDS_TYPE; // special key for mapping(This name is absolutely not used as a bucket name)
|
static constexpr char KEYVAL_FIELDS_TYPE[] = "\t"; // special key for mapping(This name is absolutely not used as a bucket name)
|
||||||
static const char* AWS_ACCESSKEYID;
|
static constexpr char AWS_ACCESSKEYID[] = "AWSAccessKeyId";
|
||||||
static const char* AWS_SECRETKEY;
|
static constexpr char AWS_SECRETKEY[] = "AWSSecretKey";
|
||||||
|
|
||||||
static const int IAM_EXPIRE_MERGIN;
|
static constexpr int IAM_EXPIRE_MERGIN = 20 * 60; // update timing
|
||||||
static const char* ECS_IAM_ENV_VAR;
|
static constexpr char ECS_IAM_ENV_VAR[] = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI";
|
||||||
static const char* IAMCRED_ACCESSKEYID;
|
static constexpr char IAMCRED_ACCESSKEYID[] = "AccessKeyId";
|
||||||
static const char* IAMCRED_SECRETACCESSKEY;
|
static constexpr char IAMCRED_SECRETACCESSKEY[] = "SecretAccessKey";
|
||||||
static const char* IAMCRED_ROLEARN;
|
static constexpr char IAMCRED_ROLEARN[] = "RoleArn";
|
||||||
|
|
||||||
static std::string bucket_name;
|
static std::string bucket_name;
|
||||||
|
|
||||||
@ -89,10 +89,10 @@ class S3fsCred
|
|||||||
fp_UpdateS3fsCredential pFuncCredUpdate;
|
fp_UpdateS3fsCredential pFuncCredUpdate;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const char* IAMv2_token_url;
|
static constexpr char IAMv2_token_url[] = "http://169.254.169.254/latest/api/token";
|
||||||
static int IAMv2_token_ttl;
|
static constexpr int IAMv2_token_ttl = 21600;
|
||||||
static const char* IAMv2_token_ttl_hdr;
|
static constexpr char IAMv2_token_ttl_hdr[] = "X-aws-ec2-metadata-token-ttl-seconds";
|
||||||
static const char* IAMv2_token_hdr;
|
static constexpr char IAMv2_token_hdr[] = "X-aws-ec2-metadata-token";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool ParseIAMRoleFromMetaDataResponse(const char* response, std::string& rolename);
|
static bool ParseIAMRoleFromMetaDataResponse(const char* response, std::string& rolename);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Contents
|
// Contents
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
static const char help_string[] =
|
static constexpr char help_string[] =
|
||||||
"\n"
|
"\n"
|
||||||
"Mount an Amazon S3 bucket as a file system.\n"
|
"Mount an Amazon S3 bucket as a file system.\n"
|
||||||
"\n"
|
"\n"
|
||||||
@ -638,7 +638,7 @@ void show_version()
|
|||||||
|
|
||||||
const char* short_version()
|
const char* short_version()
|
||||||
{
|
{
|
||||||
static const char short_ver[] = "s3fs version " VERSION "(" COMMIT_HASH_VAL ")";
|
static constexpr char short_ver[] = "s3fs version " VERSION "(" COMMIT_HASH_VAL ")";
|
||||||
return short_ver;
|
return short_ver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// S3fsLog class : variables
|
// S3fsLog class : variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
const int S3fsLog::NEST_MAX;
|
constexpr char S3fsLog::LOGFILEENV[];
|
||||||
const char* const S3fsLog::nest_spaces[S3fsLog::NEST_MAX] = {"", " ", " ", " "};
|
constexpr const char* S3fsLog::nest_spaces[];
|
||||||
const char S3fsLog::LOGFILEENV[] = "S3FS_LOGFILE";
|
constexpr char S3fsLog::MSGTIMESTAMP[];
|
||||||
const char S3fsLog::MSGTIMESTAMP[] = "S3FS_MSGTIMESTAMP";
|
|
||||||
S3fsLog* S3fsLog::pSingleton = nullptr;
|
S3fsLog* S3fsLog::pSingleton = nullptr;
|
||||||
S3fsLog::s3fs_log_level S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
S3fsLog::s3fs_log_level S3fsLog::debug_level = S3fsLog::LEVEL_CRIT;
|
||||||
FILE* S3fsLog::logfp = nullptr;
|
FILE* S3fsLog::logfp = nullptr;
|
||||||
|
@ -51,10 +51,10 @@ class S3fsLog
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const int NEST_MAX = 4;
|
static constexpr int NEST_MAX = 4;
|
||||||
static const char* const nest_spaces[NEST_MAX];
|
static constexpr const char* nest_spaces[NEST_MAX] = {"", " ", " ", " "};
|
||||||
static const char LOGFILEENV[];
|
static constexpr char LOGFILEENV[] = "S3FS_LOGFILE";
|
||||||
static const char MSGTIMESTAMP[];
|
static constexpr char MSGTIMESTAMP[] = "S3FS_MSGTIMESTAMP";
|
||||||
|
|
||||||
static S3fsLog* pSingleton;
|
static S3fsLog* pSingleton;
|
||||||
static s3fs_log_level debug_level;
|
static s3fs_log_level debug_level;
|
||||||
@ -76,7 +76,7 @@ class S3fsLog
|
|||||||
static bool IsS3fsLogInfo() { return IsS3fsLogLevel(LEVEL_INFO); }
|
static bool IsS3fsLogInfo() { return IsS3fsLogLevel(LEVEL_INFO); }
|
||||||
static bool IsS3fsLogDbg() { return IsS3fsLogLevel(LEVEL_DBG); }
|
static bool IsS3fsLogDbg() { return IsS3fsLogLevel(LEVEL_DBG); }
|
||||||
|
|
||||||
static int GetSyslogLevel(s3fs_log_level level)
|
static constexpr int GetSyslogLevel(s3fs_log_level level)
|
||||||
{
|
{
|
||||||
return ( LEVEL_DBG == (level & LEVEL_DBG) ? LOG_DEBUG :
|
return ( LEVEL_DBG == (level & LEVEL_DBG) ? LOG_DEBUG :
|
||||||
LEVEL_INFO == (level & LEVEL_DBG) ? LOG_INFO :
|
LEVEL_INFO == (level & LEVEL_DBG) ? LOG_INFO :
|
||||||
@ -86,7 +86,7 @@ class S3fsLog
|
|||||||
|
|
||||||
static std::string GetCurrentTime();
|
static std::string GetCurrentTime();
|
||||||
|
|
||||||
static const char* GetLevelString(s3fs_log_level level)
|
static constexpr const char* GetLevelString(s3fs_log_level level)
|
||||||
{
|
{
|
||||||
return ( LEVEL_DBG == (level & LEVEL_DBG) ? "[DBG] " :
|
return ( LEVEL_DBG == (level & LEVEL_DBG) ? "[DBG] " :
|
||||||
LEVEL_INFO == (level & LEVEL_DBG) ? "[INF] " :
|
LEVEL_INFO == (level & LEVEL_DBG) ? "[INF] " :
|
||||||
@ -94,13 +94,9 @@ class S3fsLog
|
|||||||
LEVEL_ERR == (level & LEVEL_DBG) ? "[ERR] " : "[CRT] " );
|
LEVEL_ERR == (level & LEVEL_DBG) ? "[ERR] " : "[CRT] " );
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* GetS3fsLogNest(int nest)
|
static constexpr const char* GetS3fsLogNest(int nest)
|
||||||
{
|
{
|
||||||
if(nest < NEST_MAX){
|
return nest_spaces[nest < NEST_MAX ? nest : NEST_MAX - 1];
|
||||||
return nest_spaces[nest];
|
|
||||||
}else{
|
|
||||||
return nest_spaces[NEST_MAX - 1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsSetLogFile()
|
static bool IsSetLogFile()
|
||||||
|
@ -444,11 +444,6 @@ void print_launch_message(int argc, char** argv)
|
|||||||
S3FS_PRN_LAUNCH_INFO("%s", message.c_str());
|
S3FS_PRN_LAUNCH_INFO("%s", message.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
|
||||||
// Utility for nanosecond time(timespec)
|
|
||||||
//-------------------------------------------------------------------
|
|
||||||
const struct timespec S3FS_OMIT_TS = {0, UTIME_OMIT};
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// result: -1 ts1 < ts2
|
// result: -1 ts1 < ts2
|
||||||
// 0 ts1 == ts2
|
// 0 ts1 == ts2
|
||||||
|
@ -66,7 +66,11 @@ enum class stat_time_type{
|
|||||||
MTIME,
|
MTIME,
|
||||||
CTIME
|
CTIME
|
||||||
};
|
};
|
||||||
extern const struct timespec S3FS_OMIT_TS;
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
// Utility for nanosecond time(timespec)
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
static constexpr struct timespec S3FS_OMIT_TS = {0, UTIME_OMIT};
|
||||||
|
|
||||||
int compare_timespec(const struct timespec& ts1, const struct timespec& ts2);
|
int compare_timespec(const struct timespec& ts1, const struct timespec& ts2);
|
||||||
int compare_timespec(const struct stat& st, stat_time_type type, const struct timespec& ts);
|
int compare_timespec(const struct stat& st, stat_time_type type, const struct timespec& ts);
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Variables
|
// Variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
static const char c_strErrorObjectName[] = "FILE or SUBDIR in DIR";
|
static constexpr char c_strErrorObjectName[] = "FILE or SUBDIR in DIR";
|
||||||
|
|
||||||
// [NOTE]
|
// [NOTE]
|
||||||
// mutex for static variables in GetXmlNsUrl
|
// mutex for static variables in GetXmlNsUrl
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Global variables
|
// Global variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
const char SPACES[] = " \t\r\n";
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Functions
|
// Functions
|
||||||
@ -147,9 +146,9 @@ std::string peeloff(std::string s)
|
|||||||
// Therefore, it is a function to use as URL encoding
|
// Therefore, it is a function to use as URL encoding
|
||||||
// for use in query strings.
|
// for use in query strings.
|
||||||
//
|
//
|
||||||
static const char* encode_general_except_chars = ".-_~"; // For general URL encode
|
static constexpr char encode_general_except_chars[] = ".-_~"; // For general URL encode
|
||||||
static const char* encode_path_except_chars = ".-_~/"; // For fuse(included path) URL encode
|
static constexpr char encode_path_except_chars[] = ".-_~/"; // For fuse(included path) URL encode
|
||||||
static const char* encode_query_except_chars = ".-_~=&%"; // For query params(and encoded string)
|
static constexpr char encode_query_except_chars[] = ".-_~=&%"; // For query params(and encoded string)
|
||||||
|
|
||||||
static std::string rawUrlEncode(const std::string &s, const char* except_chars)
|
static std::string rawUrlEncode(const std::string &s, const char* except_chars)
|
||||||
{
|
{
|
||||||
@ -381,7 +380,7 @@ std::string s3fs_hex_upper(const unsigned char* input, size_t length)
|
|||||||
|
|
||||||
std::string s3fs_base64(const unsigned char* input, size_t length)
|
std::string s3fs_base64(const unsigned char* input, size_t length)
|
||||||
{
|
{
|
||||||
static const char base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
static constexpr char base[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
result.reserve(((length + 3 - 1) / 3) * 4 + 1);
|
result.reserve(((length + 3 - 1) / 3) * 4 + 1);
|
||||||
@ -460,7 +459,7 @@ std::string s3fs_decode64(const char* input, size_t input_len)
|
|||||||
|
|
||||||
// Base location for transform. The range 0xE000 - 0xF8ff
|
// Base location for transform. The range 0xE000 - 0xF8ff
|
||||||
// is a private range, se use the start of this range.
|
// is a private range, se use the start of this range.
|
||||||
static const unsigned int escape_base = 0xe000;
|
static constexpr unsigned int escape_base = 0xe000;
|
||||||
|
|
||||||
// encode bytes into wobbly utf8.
|
// encode bytes into wobbly utf8.
|
||||||
// 'result' can be null. returns true if transform was needed.
|
// 'result' can be null. returns true if transform was needed.
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Global variables
|
// Global variables
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
extern const char SPACES[];
|
static constexpr char SPACES[] = " \t\r\n";
|
||||||
|
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
// Inline functions
|
// Inline functions
|
||||||
|
@ -34,27 +34,27 @@
|
|||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
// Const
|
// Const
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
const char usage_string[] = "Usage : \"mknod_test <base file path>\"";
|
static constexpr char usage_string[] = "Usage : \"mknod_test <base file path>\"";
|
||||||
|
|
||||||
const char str_mode_reg[] = "REGULAR";
|
static constexpr char str_mode_reg[] = "REGULAR";
|
||||||
const char str_mode_chr[] = "CHARACTER";
|
static constexpr char str_mode_chr[] = "CHARACTER";
|
||||||
const char str_mode_blk[] = "BLOCK";
|
static constexpr char str_mode_blk[] = "BLOCK";
|
||||||
const char str_mode_fifo[] = "FIFO";
|
static constexpr char str_mode_fifo[] = "FIFO";
|
||||||
const char str_mode_sock[] = "SOCK";
|
static constexpr char str_mode_sock[] = "SOCK";
|
||||||
|
|
||||||
const char str_ext_reg[] = "reg";
|
static constexpr char str_ext_reg[] = "reg";
|
||||||
const char str_ext_chr[] = "chr";
|
static constexpr char str_ext_chr[] = "chr";
|
||||||
const char str_ext_blk[] = "blk";
|
static constexpr char str_ext_blk[] = "blk";
|
||||||
const char str_ext_fifo[] = "fifo";
|
static constexpr char str_ext_fifo[] = "fifo";
|
||||||
const char str_ext_sock[] = "sock";
|
static constexpr char str_ext_sock[] = "sock";
|
||||||
|
|
||||||
// [NOTE]
|
// [NOTE]
|
||||||
// It would be nice if PATH_MAX could be used as is, but since there are
|
// It would be nice if PATH_MAX could be used as is, but since there are
|
||||||
// issues using on Linux and we also must support for macos, this simple
|
// issues using on Linux and we also must support for macos, this simple
|
||||||
// test program defines a fixed value for simplicity.
|
// test program defines a fixed value for simplicity.
|
||||||
//
|
//
|
||||||
static const size_t S3FS_TEST_PATH_MAX = 255;
|
static constexpr size_t S3FS_TEST_PATH_MAX = 255;
|
||||||
static const size_t MAX_BASE_PATH_LENGTH = S3FS_TEST_PATH_MAX - 5;
|
static constexpr size_t MAX_BASE_PATH_LENGTH = S3FS_TEST_PATH_MAX - 5;
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
// Test function
|
// Test function
|
||||||
|
@ -49,7 +49,7 @@ typedef std::list<std::string> strlist_t;
|
|||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
// Const
|
// Const
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
const char usage_string[] = "Usage : \"write_multiblock -f <file path> -p <start offset:size>\" (allows -f and -p multiple times.)";
|
static constexpr char usage_string[] = "Usage : \"write_multiblock -f <file path> -p <start offset:size>\" (allows -f and -p multiple times.)";
|
||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
// Utility functions
|
// Utility functions
|
||||||
|
Loading…
Reference in New Issue
Block a user