]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/otp: fixes following review
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 4 Dec 2017 13:58:43 +0000 (05:58 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 9 Apr 2018 14:02:17 +0000 (07:02 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/cls/otp/cls_otp.cc
src/cls/otp/cls_otp_ops.h

index b756f66b3c3e8e330ab801da48efba6dc472044b..d2380828a907f6b86abe4d1b0365d1b37024c86d 100644 (file)
@@ -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;
index a9642d7f872dd7cbe6a4dded5ceb120e8fdfe763..2ec1897569a53b14b464e659963b5aa481262f12 100644 (file)
@@ -9,8 +9,6 @@ struct cls_otp_set_otp_op
 {
   list<rados::cls::otp::otp_info_t> 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<string> 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<string> 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<rados::cls::otp::otp_info_t> found_entries;
 
-  cls_otp_get_otp_reply() = default;
-
   void encode(bufferlist &bl) const {
     ENCODE_START(1, 1, bl);
     ::encode(found_entries, bl);