Remove more uses of const_cast (#2006)

Follows on to #2004.
This commit is contained in:
Andrew Gaul 2022-07-28 23:37:15 +09:00 committed by GitHub
parent f9f614a474
commit 3928a7e359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 12 deletions

View File

@ -803,7 +803,7 @@ bool S3fsCurl::PushbackSseKeys(const std::string& input)
} else {
char* pbase64_key;
if(NULL != (pbase64_key = s3fs_base64(reinterpret_cast<unsigned char*>(const_cast<char*>(onekey.c_str())), onekey.length()))) {
if(NULL != (pbase64_key = s3fs_base64(reinterpret_cast<const unsigned char*>(onekey.c_str()), onekey.length()))) {
raw_key = onekey;
base64_key = pbase64_key;
delete[] pbase64_key;

View File

@ -770,7 +770,7 @@ bool FdEntity::RenamePath(const std::string& newpath, std::string& fentmapkey)
bool FdEntity::IsModified() const
{
AutoLock auto_data_lock(const_cast<pthread_mutex_t *>(&fdent_data_lock));
AutoLock auto_data_lock(&fdent_data_lock);
return pagelist.IsModified();
}

View File

@ -58,7 +58,7 @@ class FdEntity
headers_t orgmeta; // original headers at opening
off_t size_orgmeta; // original file size in original headers
pthread_mutex_t fdent_data_lock;// protects the following members
mutable pthread_mutex_t fdent_data_lock;// protects the following members
PageList pagelist;
std::string cachepath; // local cache file path
// (if this is empty, does not load/save pagelist.)

View File

@ -3759,6 +3759,7 @@ static bool set_mountpoint_attribute(struct stat& mpst)
//
static int set_bucket(const char* arg)
{
// TODO: Mutates input. Consider some other tokenization.
char *bucket_name = const_cast<char*>(arg);
if(strstr(arg, ":")){
if(strstr(arg, "://")){

View File

@ -94,7 +94,7 @@ static xmlChar* get_base_exp(xmlDocPtr doc, const char* exp)
xmlXPathContextPtr ctx = xmlXPathNewContext(doc);
if(!noxmlns && GetXmlNsUrl(doc, xmlnsurl)){
xmlXPathRegisterNs(ctx, reinterpret_cast<xmlChar*>(const_cast<char*>("s3")), reinterpret_cast<xmlChar*>(const_cast<char*>(xmlnsurl.c_str())));
xmlXPathRegisterNs(ctx, reinterpret_cast<const xmlChar*>("s3"), reinterpret_cast<const xmlChar*>(xmlnsurl.c_str()));
exp_string = "/s3:ListBucketResult/s3:";
} else {
exp_string = "/ListBucketResult/";
@ -102,7 +102,7 @@ static xmlChar* get_base_exp(xmlDocPtr doc, const char* exp)
exp_string += exp;
if(NULL == (marker_xp = xmlXPathEvalExpression(reinterpret_cast<xmlChar*>(const_cast<char*>(exp_string.c_str())), ctx))){
if(NULL == (marker_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(exp_string.c_str()), ctx))){
xmlXPathFreeContext(ctx);
return NULL;
}
@ -217,7 +217,7 @@ static xmlChar* get_exp_value_xml(xmlDocPtr doc, xmlXPathContextPtr ctx, const c
xmlChar* exp_value;
// search exp_key tag
if(NULL == (exp = xmlXPathEvalExpression(reinterpret_cast<xmlChar*>(const_cast<char*>(exp_key)), ctx))){
if(NULL == (exp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(exp_key), ctx))){
S3FS_PRN_ERR("Could not find key(%s).", exp_key);
return NULL;
}
@ -253,7 +253,7 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list)
std::string ex_date;
if(!noxmlns && GetXmlNsUrl(doc, xmlnsurl)){
xmlXPathRegisterNs(ctx, reinterpret_cast<xmlChar*>(const_cast<char*>("s3")), reinterpret_cast<xmlChar*>(const_cast<char*>(xmlnsurl.c_str())));
xmlXPathRegisterNs(ctx, reinterpret_cast<const xmlChar*>("s3"), reinterpret_cast<const xmlChar*>(xmlnsurl.c_str()));
ex_upload += "s3:";
ex_key += "s3:";
ex_id += "s3:";
@ -266,7 +266,7 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list)
// get "Upload" Tags
xmlXPathObjectPtr upload_xp;
if(NULL == (upload_xp = xmlXPathEvalExpression(reinterpret_cast<xmlChar*>(const_cast<char*>(ex_upload.c_str())), ctx))){
if(NULL == (upload_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_upload.c_str()), ctx))){
S3FS_PRN_ERR("xmlXPathEvalExpression returns null.");
return false;
}
@ -342,7 +342,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
xmlXPathObjectPtr contents_xp;
xmlNodeSetPtr content_nodes;
if(NULL == (contents_xp = xmlXPathEvalExpression(reinterpret_cast<xmlChar*>(const_cast<char*>(ex_contents)), ctx))){
if(NULL == (contents_xp = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_contents), ctx))){
S3FS_PRN_ERR("xmlXPathEvalExpression returns null.");
return -1;
}
@ -361,7 +361,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
// object name
xmlXPathObjectPtr key;
if(NULL == (key = xmlXPathEvalExpression(reinterpret_cast<xmlChar*>(const_cast<char*>(ex_key)), ctx))){
if(NULL == (key = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_key), ctx))){
S3FS_PRN_WARN("key is null. but continue.");
continue;
}
@ -383,7 +383,7 @@ int append_objects_from_xml_ex(const char* path, xmlDocPtr doc, xmlXPathContextP
if(!isCPrefix && ex_etag){
// Get ETag
xmlXPathObjectPtr ETag;
if(NULL != (ETag = xmlXPathEvalExpression(reinterpret_cast<xmlChar*>(const_cast<char*>(ex_etag)), ctx))){
if(NULL != (ETag = xmlXPathEvalExpression(reinterpret_cast<const xmlChar*>(ex_etag), ctx))){
if(xmlXPathNodeSetIsEmpty(ETag->nodesetval)){
S3FS_PRN_INFO("ETag->nodesetval is empty.");
}else{
@ -439,7 +439,7 @@ int append_objects_from_xml(const char* path, xmlDocPtr doc, S3ObjList& head)
xmlXPathContextPtr ctx = xmlXPathNewContext(doc);
if(!noxmlns && GetXmlNsUrl(doc, xmlnsurl)){
xmlXPathRegisterNs(ctx, reinterpret_cast<xmlChar*>(const_cast<char*>("s3")), reinterpret_cast<xmlChar*>(const_cast<char*>(xmlnsurl.c_str())));
xmlXPathRegisterNs(ctx, reinterpret_cast<const xmlChar*>("s3"), reinterpret_cast<const xmlChar*>(xmlnsurl.c_str()));
ex_contents+= "s3:";
ex_key += "s3:";
ex_cprefix += "s3:";