From da1457cdc0ade1439e926f3e0937d606545afd3a Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Fri, 22 Dec 2017 15:04:17 -0500 Subject: [PATCH] build: Bump language to C++17 Fix up all of the fallout from that. Signed-off-by: Adam C. Emerson --- src/CMakeLists.txt | 15 +++++---- src/common/ceph_crypto.h | 18 +++++------ src/common/config.cc | 4 ++- src/common/config.h | 3 +- src/common/dout.h | 2 +- src/os/filestore/LFNIndex.cc | 6 ++-- src/rgw/rgw_common.cc | 19 +++++------ src/rgw/rgw_crypt.cc | 18 +++++------ src/rgw/rgw_file.cc | 2 +- src/rgw/rgw_iam_policy.cc | 36 ++++++++++----------- src/rgw/rgw_keystone.cc | 2 +- src/rgw/rgw_op.cc | 50 ++++++++++++++--------------- src/rgw/rgw_op.h | 2 +- src/rgw/rgw_rados.cc | 8 ++--- src/rgw/rgw_rest_swift.cc | 2 +- src/rgw/rgw_torrent.cc | 8 ++--- src/test/ceph_crypto.cc | 40 +++++++++++------------ src/test/rgw/test_rgw_iam_policy.cc | 13 ++++---- 18 files changed, 123 insertions(+), 125 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4d74c4db9c53f..6337805198eab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unknown-pragmas") if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-null-sentinel -Woverloaded-virtual") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-new-ttp-matching") if(NOT WITH_OSD_INSTRUMENT_FUNCTIONS) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") endif() @@ -140,15 +141,15 @@ else(no_yasm) endif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64") endif(no_yasm) -# require c++14 -if(CMAKE_VERSION VERSION_LESS "3.1") +# require c++17 +if(CMAKE_VERSION VERSION_LESS "3.8") include(CheckCXXCompilerFlag) - CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) - if(NOT COMPILER_SUPPORTS_CXX14) + CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17) + if(NOT COMPILER_SUPPORTS_CXX17) message(FATAL_ERROR - "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support.") + "The compiler ${CMAKE_CXX_COMPILER} has no C++17 support.") endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") include(CheckCCompilerFlag) CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_SUPPORTS_GNU99) if(NOT COMPILER_SUPPORTS_GNU99) @@ -157,7 +158,7 @@ if(CMAKE_VERSION VERSION_LESS "3.1") endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") else() - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 99) diff --git a/src/common/ceph_crypto.h b/src/common/ceph_crypto.h index 9c302392923df..e5a9292dc6ff6 100644 --- a/src/common/ceph_crypto.h +++ b/src/common/ceph_crypto.h @@ -35,7 +35,7 @@ namespace ceph { class HMACSHA1: public CryptoPP::HMAC { public: - HMACSHA1 (const byte *key, size_t length) + HMACSHA1 (const ::byte *key, size_t length) : CryptoPP::HMAC(key, length) { } @@ -44,7 +44,7 @@ namespace ceph { class HMACSHA256: public CryptoPP::HMAC { public: - HMACSHA256 (const byte *key, size_t length) + HMACSHA256 (const ::byte *key, size_t length) : CryptoPP::HMAC(key, length) { } @@ -90,14 +90,14 @@ namespace ceph { s = PK11_DigestBegin(ctx); assert(s == SECSuccess); } - void Update (const byte *input, size_t length) { + void Update (const ::byte *input, size_t length) { if (length) { SECStatus s; s = PK11_DigestOp(ctx, input, length); assert(s == SECSuccess); } } - void Final (byte *digest) { + void Final (::byte *digest) { SECStatus s; unsigned int dummy; s = PK11_DigestFinal(ctx, digest, &dummy, digest_size); @@ -128,7 +128,7 @@ namespace ceph { PK11Context *ctx; unsigned int digest_size; public: - HMAC (CK_MECHANISM_TYPE cktype, unsigned int digestsize, const byte *key, size_t length) { + HMAC (CK_MECHANISM_TYPE cktype, unsigned int digestsize, const ::byte *key, size_t length) { digest_size = digestsize; slot = PK11_GetBestSlot(cktype, NULL); assert(slot); @@ -153,12 +153,12 @@ namespace ceph { s = PK11_DigestBegin(ctx); assert(s == SECSuccess); } - void Update (const byte *input, size_t length) { + void Update (const ::byte *input, size_t length) { SECStatus s; s = PK11_DigestOp(ctx, input, length); assert(s == SECSuccess); } - void Final (byte *digest) { + void Final (::byte *digest) { SECStatus s; unsigned int dummy; s = PK11_DigestFinal(ctx, digest, &dummy, digest_size); @@ -170,12 +170,12 @@ namespace ceph { class HMACSHA1 : public HMAC { public: - HMACSHA1 (const byte *key, size_t length) : HMAC(CKM_SHA_1_HMAC, CEPH_CRYPTO_HMACSHA1_DIGESTSIZE, key, length) { } + HMACSHA1 (const ::byte *key, size_t length) : HMAC(CKM_SHA_1_HMAC, CEPH_CRYPTO_HMACSHA1_DIGESTSIZE, key, length) { } }; class HMACSHA256 : public HMAC { public: - HMACSHA256 (const byte *key, size_t length) : HMAC(CKM_SHA256_HMAC, CEPH_CRYPTO_HMACSHA256_DIGESTSIZE, key, length) { } + HMACSHA256 (const ::byte *key, size_t length) : HMAC(CKM_SHA256_HMAC, CEPH_CRYPTO_HMACSHA256_DIGESTSIZE, key, length) { } }; } } diff --git a/src/common/config.cc b/src/common/config.cc index 12040e5b7da3c..cb2a756f036c1 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -89,7 +89,9 @@ md_config_t::md_config_t(bool is_daemon) << std::endl; ceph_abort(); } - schema.insert({i.name, i}); + schema.emplace(std::piecewise_construct, + std::forward_as_tuple(i.name), + std::forward_as_tuple(i)); } // Populate list of legacy_values according to the OPTION() definitions diff --git a/src/common/config.h b/src/common/config.h index ed1c23f9e373f..0e87a08080e57 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -15,6 +15,7 @@ #ifndef CEPH_CONFIG_H #define CEPH_CONFIG_H +#include #include "common/backport_std.h" #include "common/ConfUtils.h" #include "common/entity_name.h" @@ -81,7 +82,7 @@ public: * The configuration schema, in the form of Option objects describing * possible settings. */ - std::map schema; + std::map schema; /** * The current values of all settings described by the schema diff --git a/src/common/dout.h b/src/common/dout.h index 41a330ee49ab8..60bee71122ae5 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -50,7 +50,7 @@ public: do { \ if (cct->_conf->subsys.should_gather(sub, v)) { \ if (0) { \ - char __array[((v >= -1) && (v <= 200)) ? 0 : -1] __attribute__((unused)); \ + [[maybe_unused]] char __array[((v >= -1) && (v <= 200)) ? 0 : -1] = {}; \ } \ static size_t _log_exp_length = 80; \ ceph::logging::Entry *_dout_e = cct->_log->create_entry(v, sub, &_log_exp_length); \ diff --git a/src/os/filestore/LFNIndex.cc b/src/os/filestore/LFNIndex.cc index 9c4765e622b0f..9591d66e7f44c 100644 --- a/src/os/filestore/LFNIndex.cc +++ b/src/os/filestore/LFNIndex.cc @@ -1279,10 +1279,10 @@ int LFNIndex::hash_filename(const char *filename, char *hash, int buf_len) char hex[FILENAME_LFN_DIGEST_SIZE * 2]; SHA1 h; - h.Update((const byte *)filename, strlen(filename)); - h.Final((byte *)buf); + h.Update((const ::byte *)filename, strlen(filename)); + h.Final((::byte *)buf); - buf_to_hex((byte *)buf, (FILENAME_HASH_LEN + 1) / 2, hex); + buf_to_hex((::byte *)buf, (FILENAME_HASH_LEN + 1) / 2, hex); strncpy(hash, hex, FILENAME_HASH_LEN); hash[FILENAME_HASH_LEN] = '\0'; return 0; diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 3f6211012ec40..06e49df231c17 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -36,9 +36,6 @@ #define dout_context g_ceph_context #define dout_subsys ceph_subsys_rgw -using boost::none; -using boost::optional; - using rgw::IAM::ARN; using rgw::IAM::Effect; using rgw::IAM::op_to_perm; @@ -1087,11 +1084,11 @@ bool verify_requester_payer_permission(struct req_state *s) } namespace { -Effect eval_or_pass(const optional& policy, - const rgw::IAM::Environment& env, - const rgw::auth::Identity& id, - const uint64_t op, - const ARN& arn) { +Effect eval_or_pass(const boost::optional& policy, + const rgw::IAM::Environment& env, + const rgw::auth::Identity& id, + const uint64_t op, + const ARN& arn) { if (!policy) return Effect::Pass; else @@ -1103,7 +1100,7 @@ bool verify_bucket_permission(struct req_state * const s, const rgw_bucket& bucket, RGWAccessControlPolicy * const user_acl, RGWAccessControlPolicy * const bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, const uint64_t op) { if (!verify_requester_payer_permission(s)) @@ -1188,7 +1185,7 @@ static inline bool check_deferred_bucket_perms(struct req_state * const s, const rgw_bucket& bucket, RGWAccessControlPolicy * const user_acl, RGWAccessControlPolicy * const bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, const uint8_t deferred_check, const uint64_t op) { @@ -1211,7 +1208,7 @@ bool verify_object_permission(struct req_state * const s, RGWAccessControlPolicy * const user_acl, RGWAccessControlPolicy * const bucket_acl, RGWAccessControlPolicy * const object_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, const uint64_t op) { if (!verify_requester_payer_permission(s)) diff --git a/src/rgw/rgw_crypt.cc b/src/rgw/rgw_crypt.cc index cc23bf0bef71a..9e4e5c0a1dfe6 100644 --- a/src/rgw/rgw_crypt.cc +++ b/src/rgw/rgw_crypt.cc @@ -81,7 +81,7 @@ public: #ifdef USE_CRYPTOPP bool encrypt(bufferlist& input, off_t in_ofs, size_t size, bufferlist& output, off_t stream_offset) { - byte iv[AES_256_IVSIZE]; + ::byte iv[AES_256_IVSIZE]; ldout(cct, 25) << "Encrypt in_ofs " << in_ofs << " size=" << size @@ -98,7 +98,7 @@ public: CTR_Mode< AES >::Encryption e; e.SetKeyWithIV(key, AES_256_KEYSIZE, iv, AES_256_IVSIZE); buf.zero(); - e.ProcessData((byte*)buf.c_str(), (byte*)buf.c_str(), buf.length()); + e.ProcessData((::byte*)buf.c_str(), (::byte*)buf.c_str(), buf.length()); buf.set_length(size); off_t plaintext_pos = in_ofs; off_t crypt_pos = 0; @@ -110,8 +110,8 @@ public: } while (iter != input.buffers().end()) { off_t cnt = std::min(iter->length() - plaintext_pos, size - crypt_pos); - byte* src = (byte*)iter->c_str() + plaintext_pos; - byte* dst = (byte*)buf.c_str() + crypt_pos; + auto src = (::byte*)iter->c_str() + plaintext_pos; + auto dst = (::byte*)buf.c_str() + crypt_pos; for (off_t i = 0; i < cnt; i++) { dst[i] ^= src[i]; } @@ -195,7 +195,7 @@ public: return encrypt(input, in_ofs, size, output, stream_offset); } - void prepare_iv(byte iv[AES_256_IVSIZE], off_t offset) { + void prepare_iv(::byte iv[AES_256_IVSIZE], off_t offset) { off_t index = offset / AES_256_IVSIZE; off_t i = AES_256_IVSIZE - 1; unsigned int val; @@ -515,7 +515,7 @@ public: } - void prepare_iv(byte (&iv)[AES_256_IVSIZE], off_t offset) { + void prepare_iv(::byte (&iv)[AES_256_IVSIZE], off_t offset) { off_t index = offset / AES_256_IVSIZE; off_t i = AES_256_IVSIZE - 1; unsigned int val; @@ -1098,8 +1098,8 @@ int rgw_s3_prepare_encrypt(struct req_state* s, } MD5 key_hash; - byte key_hash_res[CEPH_CRYPTO_MD5_DIGESTSIZE]; - key_hash.Update(reinterpret_cast(key_bin.c_str()), key_bin.size()); + ::byte key_hash_res[CEPH_CRYPTO_MD5_DIGESTSIZE]; + key_hash.Update(reinterpret_cast(key_bin.c_str()), key_bin.size()); key_hash.Final(key_hash_res); if (memcmp(key_hash_res, keymd5_bin.c_str(), CEPH_CRYPTO_MD5_DIGESTSIZE) != 0) { @@ -1335,7 +1335,7 @@ int rgw_s3_prepare_decrypt(struct req_state* s, MD5 key_hash; uint8_t key_hash_res[CEPH_CRYPTO_MD5_DIGESTSIZE]; - key_hash.Update(reinterpret_cast(key_bin.c_str()), key_bin.size()); + key_hash.Update(reinterpret_cast(key_bin.c_str()), key_bin.size()); key_hash.Final(key_hash_res); if ((memcmp(key_hash_res, keymd5_bin.c_str(), CEPH_CRYPTO_MD5_DIGESTSIZE) != 0) || diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 1c0d1c75b39dc..818afa44879c0 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1363,7 +1363,7 @@ namespace rgw { if (need_to_wait) { orig_data = data; } - hash.Update((const byte *)data.c_str(), data.length()); + hash.Update((const ::byte *)data.c_str(), data.length()); op_ret = put_data_and_throttle(filter, data, ofs, need_to_wait); if (op_ret < 0) { if (!need_to_wait || op_ret != -EEXIST) { diff --git a/src/rgw/rgw_iam_policy.cc b/src/rgw/rgw_iam_policy.cc index ea07310f4c419..11078d494c02b 100644 --- a/src/rgw/rgw_iam_policy.cc +++ b/src/rgw/rgw_iam_policy.cc @@ -34,8 +34,6 @@ using std::uint64_t; using std::unordered_map; using boost::container::flat_set; -using boost::none; -using boost::optional; using boost::regex; using boost::regex_constants::ECMAScript; using boost::regex_constants::optimize; @@ -63,8 +61,8 @@ struct actpair { }; namespace { -optional to_partition(const smatch::value_type& p, - bool wildcards) { +boost::optional to_partition(const smatch::value_type& p, + bool wildcards) { if (p == "aws") { return Partition::aws; } else if (p == "aws-cn") { @@ -74,14 +72,14 @@ optional to_partition(const smatch::value_type& p, } else if (p == "*" && wildcards) { return Partition::wildcard; } else { - return none; + return boost::none; } ceph_abort(); } -optional to_service(const smatch::value_type& s, - bool wildcards) { +boost::optional to_service(const smatch::value_type& s, + bool wildcards) { static const unordered_map services = { { "acm", Service::acm }, { "apigateway", Service::apigateway }, @@ -170,7 +168,7 @@ optional to_service(const smatch::value_type& s, auto i = services.find(s); if (i == services.end()) { - return none; + return boost::none; } else { return i->second; } @@ -205,7 +203,7 @@ ARN::ARN(const rgw_bucket& b, const string& o) resource.append(o); } -optional ARN::parse(const string& s, bool wildcards) { +boost::optional ARN::parse(const string& s, bool wildcards) { static const char str_wild[] = "arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)"; static const regex rx_wild(str_wild, sizeof(str_wild) - 1, @@ -228,7 +226,7 @@ optional ARN::parse(const string& s, bool wildcards) { } } } - return none; + return boost::none; } string ARN::to_string() const { @@ -721,8 +719,8 @@ bool ParseState::key(const char* s, size_t l) { // I should just rewrite a few helper functions to use iterators, // which will make all of this ever so much nicer. -static optional parse_principal(CephContext* cct, TokenID t, - string&& s) { +static boost::optional parse_principal(CephContext* cct, TokenID t, + string&& s) { // Wildcard! if ((t == TokenID::AWS) && (s == "*")) { return Principal::wildcard(); @@ -1048,10 +1046,10 @@ bool Condition::eval(const Environment& env) const { } } -optional Condition::as_network(const string& s) { +boost::optional Condition::as_network(const string& s) { MaskedIP m; if (s.empty()) { - return none; + return boost::none; } m.v6 = (s.find(':') == string::npos) ? false : true; @@ -1064,7 +1062,7 @@ optional Condition::as_network(const string& s) { m.prefix = strtoul(s.data() + slash + 1, &end, 10); if (*end != 0 || (m.v6 && m.prefix > 128) || (!m.v6 && m.prefix > 32)) { - return none; + return boost::none; } } @@ -1079,7 +1077,7 @@ optional Condition::as_network(const string& s) { if (m.v6) { struct in6_addr a; if (inet_pton(AF_INET6, p->c_str(), static_cast(&a)) != 1) { - return none; + return boost::none; } m.addr |= Address(a.s6_addr[15]) << 0; @@ -1101,7 +1099,7 @@ optional Condition::as_network(const string& s) { } else { struct in_addr a; if (inet_pton(AF_INET, p->c_str(), static_cast(&a)) != 1) { - return none; + return boost::none; } m.addr = ntohl(a.s_addr); @@ -1233,7 +1231,7 @@ ostream& operator <<(ostream& m, const Condition& c) { } Effect Statement::eval(const Environment& e, - optional ida, + boost::optional ida, uint64_t act, const ARN& res) const { if (ida && (!ida->is_identity(princ) || ida->is_identity(noprinc))) { return Effect::Pass; @@ -1538,7 +1536,7 @@ Policy::Policy(CephContext* cct, const string& tenant, } Effect Policy::eval(const Environment& e, - optional ida, + boost::optional ida, std::uint64_t action, const ARN& resource) const { auto allowed = false; for (auto& s : statements) { diff --git a/src/rgw/rgw_keystone.cc b/src/rgw/rgw_keystone.cc index 3294380ba100c..eea1d2922c7c4 100644 --- a/src/rgw/rgw_keystone.cc +++ b/src/rgw/rgw_keystone.cc @@ -113,7 +113,7 @@ void rgw_get_token_id(const string& token, string& token_id) unsigned char m[CEPH_CRYPTO_MD5_DIGESTSIZE]; MD5 hash; - hash.Update((const byte *)token.c_str(), token.size()); + hash.Update((const ::byte *)token.c_str(), token.size()); hash.Final(m); char calc_md5[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 1]; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 666ef23946260..1f97a35e41176 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -242,10 +242,10 @@ static int get_bucket_policy_from_attr(CephContext *cct, return get_bucket_instance_policy_from_attr(cct, store, bucket_info, bucket_attrs, policy); } -static optional get_iam_policy_from_attr(CephContext* cct, - RGWRados* store, - map& attrs, - const string& tenant) { +static boost::optional get_iam_policy_from_attr(CephContext* cct, + RGWRados* store, + map& attrs, + const string& tenant) { auto i = attrs.find(RGW_ATTR_IAM_POLICY); if (i != attrs.end()) { return Policy(cct, tenant, i->second); @@ -323,7 +323,7 @@ static int read_obj_policy(RGWRados *store, RGWBucketInfo& bucket_info, map& bucket_attrs, RGWAccessControlPolicy* acl, - optional& policy, + boost::optional& policy, rgw_bucket& bucket, rgw_obj_key& object) { @@ -1047,7 +1047,7 @@ bool RGWOp::generate_cors_headers(string& origin, string& method, string& header int RGWGetObj::read_user_manifest_part(rgw_bucket& bucket, const rgw_bucket_dir_entry& ent, RGWAccessControlPolicy * const bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, const off_t start_ofs, const off_t end_ofs) { @@ -1146,14 +1146,14 @@ static int iterate_user_manifest_parts(CephContext * const cct, RGWBucketInfo *pbucket_info, const string& obj_prefix, RGWAccessControlPolicy * const bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, uint64_t * const ptotal_len, uint64_t * const pobj_size, string * const pobj_sum, int (*cb)(rgw_bucket& bucket, const rgw_bucket_dir_entry& ent, RGWAccessControlPolicy * const bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, off_t start_ofs, off_t end_ofs, void *param), @@ -1194,7 +1194,7 @@ static int iterate_user_manifest_parts(CephContext * const cct, obj_ofs += obj_size; if (pobj_sum) { - etag_sum.Update((const byte *)ent.meta.etag.c_str(), + etag_sum.Update((const ::byte *)ent.meta.etag.c_str(), ent.meta.etag.length()); } @@ -1252,7 +1252,7 @@ static int iterate_slo_parts(CephContext *cct, int (*cb)(rgw_bucket& bucket, const rgw_bucket_dir_entry& ent, RGWAccessControlPolicy *bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, off_t start_ofs, off_t end_ofs, void *param), @@ -1304,7 +1304,7 @@ static int iterate_slo_parts(CephContext *cct, // SLO is a Swift thing, and Swift has no knowledge of S3 Policies. int r = cb(part.bucket, ent, part.bucket_acl, (part.bucket_policy ? - optional(*part.bucket_policy) : none), + boost::optional(*part.bucket_policy) : none), start_ofs, end_ofs, cb_param); if (r < 0) return r; @@ -1320,7 +1320,7 @@ static int iterate_slo_parts(CephContext *cct, static int get_obj_user_manifest_iterate_cb(rgw_bucket& bucket, const rgw_bucket_dir_entry& ent, RGWAccessControlPolicy * const bucket_acl, - const optional& bucket_policy, + const boost::optional& bucket_policy, const off_t start_ofs, const off_t end_ofs, void * const param) @@ -1347,8 +1347,8 @@ int RGWGetObj::handle_user_manifest(const char *prefix) RGWAccessControlPolicy _bucket_acl(s->cct); RGWAccessControlPolicy *bucket_acl; - optional _bucket_policy; - optional* bucket_policy; + boost::optional _bucket_policy; + boost::optional* bucket_policy; RGWBucketInfo bucket_info; RGWBucketInfo *pbucket_info; @@ -1441,7 +1441,7 @@ int RGWGetObj::handle_slo_manifest(bufferlist& bl) ldout(s->cct, 2) << "RGWGetObj::handle_slo_manifest()" << dendl; vector allocated_acls; - map>> policies; + map>> policies; map buckets; map slo_parts; @@ -1532,7 +1532,7 @@ int RGWGetObj::handle_slo_manifest(bufferlist& bl) << " etag=" << part.etag << dendl; - etag_sum.Update((const byte *)entry.etag.c_str(), + etag_sum.Update((const ::byte *)entry.etag.c_str(), entry.etag.length()); slo_parts[total_len] = part; @@ -2960,7 +2960,7 @@ int RGWPutObj::verify_permission() if (copy_source) { RGWAccessControlPolicy cs_acl(s->cct); - optional policy; + boost::optional policy; map cs_attrs; rgw_bucket cs_bucket(copy_source_bucket_info.bucket); rgw_obj_key cs_object(copy_source_object_name, copy_source_version_id); @@ -3449,7 +3449,7 @@ void RGWPutObj::execute() } if (need_calc_md5) { - hash.Update((const byte *)data.c_str(), data.length()); + hash.Update((const ::byte *)data.c_str(), data.length()); } /* update torrrent */ @@ -3595,7 +3595,7 @@ void RGWPutObj::execute() ::encode(*slo_info, manifest_bl); emplace_attr(RGW_ATTR_SLO_MANIFEST, std::move(manifest_bl)); - hash.Update((byte *)slo_info->raw_data, slo_info->raw_data_len); + hash.Update((::byte *)slo_info->raw_data, slo_info->raw_data_len); complete_etag(hash, &etag); ldout(s->cct, 10) << __func__ << ": calculated md5 for user manifest: " << etag << dendl; } @@ -3785,7 +3785,7 @@ void RGWPostObj::execute() break; } - hash.Update((const byte *)data.c_str(), data.length()); + hash.Update((const ::byte *)data.c_str(), data.length()); op_ret = put_data_and_throttle(filter, data, ofs, false); ofs += len; @@ -4352,7 +4352,7 @@ bool RGWCopyObj::parse_copy_location(const string& url_src, string& bucket_name, int RGWCopyObj::verify_permission() { RGWAccessControlPolicy src_acl(s->cct); - optional src_policy; + boost::optional src_policy; op_ret = get_params(); if (op_ret < 0) return op_ret; @@ -4860,7 +4860,7 @@ void RGWPutLC::execute() MD5 data_hash; unsigned char data_hash_res[CEPH_CRYPTO_MD5_DIGESTSIZE]; - data_hash.Update(reinterpret_cast(data), len); + data_hash.Update(reinterpret_cast(data), len); data_hash.Final(data_hash_res); if (memcmp(data_hash_res, content_md5_bin.c_str(), CEPH_CRYPTO_MD5_DIGESTSIZE) != 0) { @@ -5445,7 +5445,7 @@ void RGWCompleteMultipart::execute() hex_to_buf(obj_iter->second.etag.c_str(), petag, CEPH_CRYPTO_MD5_DIGESTSIZE); - hash.Update((const byte *)petag, sizeof(petag)); + hash.Update((const ::byte *)petag, sizeof(petag)); RGWUploadPartInfo& obj_part = obj_iter->second; @@ -5498,7 +5498,7 @@ void RGWCompleteMultipart::execute() accounted_size += obj_part.accounted_size; } } while (truncated); - hash.Final((byte *)final_etag); + hash.Final((::byte *)final_etag); buf_to_hex((unsigned char *)final_etag, sizeof(final_etag), final_etag_str); snprintf(&final_etag_str[CEPH_CRYPTO_MD5_DIGESTSIZE * 2], sizeof(final_etag_str) - CEPH_CRYPTO_MD5_DIGESTSIZE * 2, @@ -6424,7 +6424,7 @@ int RGWBulkUploadOp::handle_file(const boost::string_ref path, op_ret = len; return op_ret; } else if (len > 0) { - hash.Update((const byte *)data.c_str(), data.length()); + hash.Update((const ::byte *)data.c_str(), data.length()); op_ret = put_data_and_throttle(filter, data, ofs, false); if (op_ret < 0) { ldout(s->cct, 20) << "processor->thottle_data() returned ret=" diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 8e0c74f7c9e05..079bda6d53c80 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -2039,7 +2039,7 @@ static inline void complete_etag(MD5& hash, string *etag) char etag_buf[CEPH_CRYPTO_MD5_DIGESTSIZE]; char etag_buf_str[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 16]; - hash.Final((byte *)etag_buf); + hash.Final((::byte *)etag_buf); buf_to_hex((const unsigned char *)etag_buf, CEPH_CRYPTO_MD5_DIGESTSIZE, etag_buf_str); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 393a4ccebb864..c1fa1a964abae 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1915,7 +1915,7 @@ static uint32_t gen_short_zone_id(const std::string zone_id) { unsigned char md5[CEPH_CRYPTO_MD5_DIGESTSIZE]; MD5 hash; - hash.Update((const byte *)zone_id.c_str(), zone_id.size()); + hash.Update((const ::byte *)zone_id.c_str(), zone_id.size()); hash.Final(md5); uint32_t short_id; @@ -3994,7 +3994,7 @@ int RGWRados::replace_region_with_zonegroup() unsigned char md5[CEPH_CRYPTO_MD5_DIGESTSIZE]; char md5_str[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 1]; MD5 hash; - hash.Update((const byte *)new_realm_name.c_str(), new_realm_name.length()); + hash.Update((const ::byte *)new_realm_name.c_str(), new_realm_name.length()); hash.Final(md5); buf_to_hex(md5, CEPH_CRYPTO_MD5_DIGESTSIZE, md5_str); string new_realm_id(md5_str); @@ -9059,12 +9059,12 @@ static void generate_fake_tag(RGWRados *store, map& attrset, unsigned char md5[CEPH_CRYPTO_MD5_DIGESTSIZE]; char md5_str[CEPH_CRYPTO_MD5_DIGESTSIZE * 2 + 1]; MD5 hash; - hash.Update((const byte *)manifest_bl.c_str(), manifest_bl.length()); + hash.Update((const ::byte *)manifest_bl.c_str(), manifest_bl.length()); map::iterator iter = attrset.find(RGW_ATTR_ETAG); if (iter != attrset.end()) { bufferlist& bl = iter->second; - hash.Update((const byte *)bl.c_str(), bl.length()); + hash.Update((const ::byte *)bl.c_str(), bl.length()); } hash.Final(md5); diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 958ebc9e77bde..e371dee8e18b2 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -889,7 +889,7 @@ int RGWPutObj_ObjStore_SWIFT::get_params() MD5 etag_sum; uint64_t total_size = 0; for (const auto& entry : slo_info->entries) { - etag_sum.Update((const byte *)entry.etag.c_str(), + etag_sum.Update((const ::byte *)entry.etag.c_str(), entry.etag.length()); total_size += entry.size_bytes; diff --git a/src/rgw/rgw_torrent.cc b/src/rgw/rgw_torrent.cc index cff77b3d981cd..7df0f0cf7360f 100644 --- a/src/rgw/rgw_torrent.cc +++ b/src/rgw/rgw_torrent.cc @@ -156,8 +156,8 @@ void seed::sha1(SHA1 *h, bufferlist &bl, off_t bl_len) for (off_t i = 0; i < num; i++) { memset(sha, 0x00, sizeof(sha)); - h->Update((byte *)pstr, info.piece_length); - h->Final((byte *)sha); + h->Update((::byte *)pstr, info.piece_length); + h->Final((::byte *)sha); set_info_pieces(sha); pstr += info.piece_length; } @@ -166,8 +166,8 @@ void seed::sha1(SHA1 *h, bufferlist &bl, off_t bl_len) if (0 != remain) { memset(sha, 0x00, sizeof(sha)); - h->Update((byte *)pstr, remain); - h->Final((byte *)sha); + h->Update((::byte *)pstr, remain); + h->Final((::byte *)sha); set_info_pieces(sha); } } diff --git a/src/test/ceph_crypto.cc b/src/test/ceph_crypto.cc index 86b5c62cfc19d..030e8a87c1c33 100644 --- a/src/test/ceph_crypto.cc +++ b/src/test/ceph_crypto.cc @@ -14,7 +14,7 @@ public: TEST(MD5, Simple) { ceph::crypto::MD5 h; - h.Update((const byte*)"foo", 3); + h.Update((const ::byte*)"foo", 3); unsigned char digest[CEPH_CRYPTO_MD5_DIGESTSIZE]; h.Final(digest); int err; @@ -28,11 +28,11 @@ TEST(MD5, Simple) { TEST(MD5, MultiUpdate) { ceph::crypto::MD5 h; - h.Update((const byte*)"", 0); - h.Update((const byte*)"fo", 2); - h.Update((const byte*)"", 0); - h.Update((const byte*)"o", 1); - h.Update((const byte*)"", 0); + h.Update((const ::byte*)"", 0); + h.Update((const ::byte*)"fo", 2); + h.Update((const ::byte*)"", 0); + h.Update((const ::byte*)"o", 1); + h.Update((const ::byte*)"", 0); unsigned char digest[CEPH_CRYPTO_MD5_DIGESTSIZE]; h.Final(digest); int err; @@ -46,9 +46,9 @@ TEST(MD5, MultiUpdate) { TEST(MD5, Restart) { ceph::crypto::MD5 h; - h.Update((const byte*)"bar", 3); + h.Update((const ::byte*)"bar", 3); h.Restart(); - h.Update((const byte*)"foo", 3); + h.Update((const ::byte*)"foo", 3); unsigned char digest[CEPH_CRYPTO_MD5_DIGESTSIZE]; h.Final(digest); int err; @@ -61,8 +61,8 @@ TEST(MD5, Restart) { } TEST(HMACSHA1, Simple) { - ceph::crypto::HMACSHA1 h((const byte*)"sekrit", 6); - h.Update((const byte*)"foo", 3); + ceph::crypto::HMACSHA1 h((const ::byte*)"sekrit", 6); + h.Update((const ::byte*)"foo", 3); unsigned char digest[CEPH_CRYPTO_HMACSHA1_DIGESTSIZE]; h.Final(digest); int err; @@ -75,12 +75,12 @@ TEST(HMACSHA1, Simple) { } TEST(HMACSHA1, MultiUpdate) { - ceph::crypto::HMACSHA1 h((const byte*)"sekrit", 6); - h.Update((const byte*)"", 0); - h.Update((const byte*)"fo", 2); - h.Update((const byte*)"", 0); - h.Update((const byte*)"o", 1); - h.Update((const byte*)"", 0); + ceph::crypto::HMACSHA1 h((const ::byte*)"sekrit", 6); + h.Update((const ::byte*)"", 0); + h.Update((const ::byte*)"fo", 2); + h.Update((const ::byte*)"", 0); + h.Update((const ::byte*)"o", 1); + h.Update((const ::byte*)"", 0); unsigned char digest[CEPH_CRYPTO_HMACSHA1_DIGESTSIZE]; h.Final(digest); int err; @@ -93,10 +93,10 @@ TEST(HMACSHA1, MultiUpdate) { } TEST(HMACSHA1, Restart) { - ceph::crypto::HMACSHA1 h((const byte*)"sekrit", 6); - h.Update((const byte*)"bar", 3); + ceph::crypto::HMACSHA1 h((const ::byte*)"sekrit", 6); + h.Update((const ::byte*)"bar", 3); h.Restart(); - h.Update((const byte*)"foo", 3); + h.Update((const ::byte*)"foo", 3); unsigned char digest[CEPH_CRYPTO_HMACSHA1_DIGESTSIZE]; h.Final(digest); int err; @@ -133,7 +133,7 @@ void do_simple_crypto() { // not exit status 0 ceph::crypto::init(g_ceph_context); ceph::crypto::MD5 h; - h.Update((const byte*)"foo", 3); + h.Update((const ::byte*)"foo", 3); unsigned char digest[CEPH_CRYPTO_MD5_DIGESTSIZE]; h.Final(digest); exit(0); diff --git a/src/test/rgw/test_rgw_iam_policy.cc b/src/test/rgw/test_rgw_iam_policy.cc index 50d428a86be90..ecad57adb72e7 100644 --- a/src/test/rgw/test_rgw_iam_policy.cc +++ b/src/test/rgw/test_rgw_iam_policy.cc @@ -35,7 +35,6 @@ using boost::container::flat_set; using boost::intrusive_ptr; using boost::make_optional; using boost::none; -using boost::optional; using rgw::auth::Identity; using rgw::auth::Principal; @@ -132,7 +131,7 @@ public: }; TEST_F(PolicyTest, Parse1) { - optional p; + boost::optional p; ASSERT_NO_THROW(p = Policy(cct.get(), arbitrary_tenant, bufferlist::static_from_string(example1))); @@ -183,7 +182,7 @@ TEST_F(PolicyTest, Eval1) { } TEST_F(PolicyTest, Parse2) { - optional p; + boost::optional p; ASSERT_NO_THROW(p = Policy(cct.get(), arbitrary_tenant, bufferlist::static_from_string(example2))); @@ -264,7 +263,7 @@ TEST_F(PolicyTest, Eval2) { } TEST_F(PolicyTest, Parse3) { - optional p; + boost::optional p; ASSERT_NO_THROW(p = Policy(cct.get(), arbitrary_tenant, bufferlist::static_from_string(example3))); @@ -622,7 +621,7 @@ TEST_F(IPPolicyTest, IPEnvironment) { } TEST_F(IPPolicyTest, ParseIPAddress) { - optional p; + boost::optional p; ASSERT_NO_THROW(p = Policy(cct.get(), arbitrary_tenant, bufferlist::static_from_string(ip_address_full_example))); @@ -659,7 +658,7 @@ TEST_F(IPPolicyTest, ParseIPAddress) { EXPECT_EQ(p->statements[0].conditions[0].vals.size(), 2U); EXPECT_EQ(p->statements[0].conditions[0].vals[0], "192.168.1.0/24"); EXPECT_EQ(p->statements[0].conditions[0].vals[1], "::1"); - optional convertedIPv4 = rgw::IAM::Condition::as_network(p->statements[0].conditions[0].vals[0]); + boost::optional convertedIPv4 = rgw::IAM::Condition::as_network(p->statements[0].conditions[0].vals[0]); EXPECT_TRUE(convertedIPv4.is_initialized()); if (convertedIPv4.is_initialized()) { EXPECT_EQ(*convertedIPv4, allowedIPv4Range); @@ -671,7 +670,7 @@ TEST_F(IPPolicyTest, ParseIPAddress) { EXPECT_EQ(p->statements[0].conditions[1].vals.size(), 2U); EXPECT_EQ(p->statements[0].conditions[1].vals[0], "192.168.1.1/32"); EXPECT_EQ(p->statements[0].conditions[1].vals[1], "2001:0db8:85a3:0000:0000:8a2e:0370:7334"); - optional convertedIPv6 = rgw::IAM::Condition::as_network(p->statements[0].conditions[1].vals[1]); + boost::optional convertedIPv6 = rgw::IAM::Condition::as_network(p->statements[0].conditions[1].vals[1]); EXPECT_TRUE(convertedIPv6.is_initialized()); if (convertedIPv6.is_initialized()) { EXPECT_EQ(*convertedIPv6, allowedIPv6); -- 2.39.5