]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rgw: usage_iterate_range truncated should never be NULL 20926/head
authorRobin H. Johnson <robin.johnson@dreamhost.com>
Mon, 12 Mar 2018 21:38:57 +0000 (14:38 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 15 Mar 2018 19:26:20 +0000 (12:26 -0700)
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>
src/cls/rgw/cls_rgw.cc

index 90191ac4c695e38df5bf117fd3ce2359c388f322..187f980cf1271e16b863193f8c947394995b387d 100644 (file)
@@ -2916,6 +2916,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 {
@@ -2938,9 +2940,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())
@@ -2954,18 +2954,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;
     }