From: Yehuda Sadeh Date: Mon, 4 Dec 2017 13:58:43 +0000 (-0800) Subject: cls/otp: fixes following review X-Git-Tag: v13.1.0~343^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4d8a6b698a534f9b4226828ebd4d7dac4e618713;p=ceph.git cls/otp: fixes following review Signed-off-by: Yehuda Sadeh --- diff --git a/src/cls/otp/cls_otp.cc b/src/cls/otp/cls_otp.cc index b756f66b3c3e8..d2380828a907f 100644 --- a/src/cls/otp/cls_otp.cc +++ b/src/cls/otp/cls_otp.cc @@ -90,7 +90,7 @@ WRITE_CLASS_ENCODER(otp_instance) void otp_instance::trim_expired(const ceph::real_time& now) { - ceph::real_time window_start = now - make_timespan(otp.step_size); + ceph::real_time window_start = now - std::chrono::seconds(otp.step_size); while (!last_checks.empty() && last_checks.front().timestamp < window_start) { @@ -150,7 +150,7 @@ void otp_instance::find(const string& token, otp_check_t *result) ceph::real_time now = real_clock::now(); trim_expired(now); - for (auto entry : boost::adaptors::reverse(last_checks)) { + for (auto& entry : boost::adaptors::reverse(last_checks)) { if (entry.token == token) { *result = entry; return; @@ -166,7 +166,7 @@ static int get_otp_instance(cls_method_context_t hctx, const string& id, otp_ins bufferlist bl; string key = otp_key_prefix + id; - int r = cls_cxx_map_get_val(hctx, key.c_str(), &bl); + int r = cls_cxx_map_get_val(hctx, key, &bl); if (r < 0) { if (r != -ENOENT) { CLS_ERR("error reading key %s: %d", key.c_str(), r); @@ -192,7 +192,7 @@ static int write_otp_instance(cls_method_context_t hctx, const otp_instance& ins bufferlist bl; ::encode(instance, bl); - int r = cls_cxx_map_set_val(hctx, key.c_str(), &bl); + int r = cls_cxx_map_set_val(hctx, key, &bl); if (r < 0) { CLS_ERR("ERROR: %s(): failed to store key (otp id=%s, r=%d)", __func__, instance.otp.id.c_str(), r); return r; @@ -205,7 +205,7 @@ static int remove_otp_instance(cls_method_context_t hctx, const string& id) { string key = otp_key_prefix + id; - int r = cls_cxx_map_remove_key(hctx, key.c_str()); + int r = cls_cxx_map_remove_key(hctx, key); if (r < 0) { CLS_ERR("ERROR: %s(): failed to remove key (otp id=%s, r=%d)", __func__, id.c_str(), r); return r; @@ -218,7 +218,7 @@ static int read_header(cls_method_context_t hctx, otp_header *h) { bufferlist bl; ::encode(h, bl); - int r = cls_cxx_map_get_val(hctx, otp_header_key.c_str(), &bl); + int r = cls_cxx_map_get_val(hctx, otp_header_key, &bl); if (r == -ENOENT || r == -ENODATA) { *h = otp_header(); return 0; @@ -249,7 +249,7 @@ static int write_header(cls_method_context_t hctx, const otp_header& h) bufferlist bl; ::encode(h, bl); - int r = cls_cxx_map_set_val(hctx, otp_header_key.c_str(), &bl); + int r = cls_cxx_map_set_val(hctx, otp_header_key, &bl); if (r < 0) { CLS_ERR("failed to store header (r=%d)", r); return r; diff --git a/src/cls/otp/cls_otp_ops.h b/src/cls/otp/cls_otp_ops.h index a9642d7f872dd..2ec1897569a53 100644 --- a/src/cls/otp/cls_otp_ops.h +++ b/src/cls/otp/cls_otp_ops.h @@ -9,8 +9,6 @@ struct cls_otp_set_otp_op { list entries; - cls_otp_set_otp_op() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(entries, bl); @@ -30,8 +28,6 @@ struct cls_otp_check_otp_op string val; string token; - cls_otp_check_otp_op() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(id, bl); @@ -53,8 +49,6 @@ struct cls_otp_get_result_op { string token; - cls_otp_get_result_op() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(token, bl); @@ -72,8 +66,6 @@ struct cls_otp_get_result_reply { rados::cls::otp::otp_check_t result; - cls_otp_get_result_reply() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(result, bl); @@ -91,8 +83,6 @@ struct cls_otp_remove_otp_op { list ids; - cls_otp_remove_otp_op() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(ids, bl); @@ -111,8 +101,6 @@ struct cls_otp_get_otp_op bool get_all{false}; list ids; - cls_otp_get_otp_op() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(get_all, bl); @@ -132,8 +120,6 @@ struct cls_otp_get_otp_reply { list found_entries; - cls_otp_get_otp_reply() = default; - void encode(bufferlist &bl) const { ENCODE_START(1, 1, bl); ::encode(found_entries, bl);