]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: usage_iterate_range truncated should never be NULL 21388/head
authorRobin H. Johnson <robin.johnson@dreamhost.com>
Mon, 12 Mar 2018 21:38:57 +0000 (14:38 -0700)
committerAbhishek Lekshmanan <abhishek@suse.com>
Thu, 12 Apr 2018 17:27:35 +0000 (19:27 +0200)
Ensuring truncated is non-NULL improves code clarity.

Suggested-by: Yehuda Sadeh <yehuda@redhat.com>
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
(cherry picked from commit f9eb79bbbf30f24135165a2a33aa2a80916b4005)

src/cls/rgw/cls_rgw.cc

index 64f85e6fa0b50d8ebac5c8b6573ea1628e1fe124..dc9da596854ab1015dda9e2baed5feafe54acfe7 100644 (file)
@@ -2920,6 +2920,8 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64
   string user_key;
   bool truncated_status = false;
 
+  assert(truncated != nullptr);
+
   if (!by_user) {
     usage_record_prefix_by_time(end, end_key);
   } else {
@@ -2942,9 +2944,7 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64
   if (ret < 0)
     return ret;
 
-  if (truncated) {
-    *truncated = truncated_status;
-  }
+  *truncated = truncated_status;
       
   map<string, bufferlist>::iterator iter = keys.begin();
   if (iter == keys.end())
@@ -2958,18 +2958,14 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64
 
     if (!by_user && key.compare(end_key) >= 0) {
       CLS_LOG(20, "usage_iterate_range reached key=%s, done", key.c_str());
-      if (truncated) {
-       *truncated = false;
-      }
+      *truncated = false;
       key_iter = key;
       return 0;
     }
 
     if (by_user && key.compare(0, user_key.size(), user_key) != 0) {
       CLS_LOG(20, "usage_iterate_range reached key=%s, done", key.c_str());
-      if (truncated) {
-       *truncated = false;
-      }
+      *truncated = false;
       key_iter = key;
       return 0;
     }