]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: initialize member variables of rgw_log_entry 32430/head
authorKefu Chai <kchai@redhat.com>
Thu, 26 Dec 2019 13:42:18 +0000 (21:42 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 26 Dec 2019 13:42:20 +0000 (21:42 +0800)
`check-generated.sh` tests the dencoder of a class by:

ceph-dencoder type rgw_log_entry select_test 2 dump_json > /tmp/foo
ceph-dencoder type rgw_log_entry select_test 2 encode decode dump_json > /tmp/bar
cmp /tmp/foo /tmp/bar

but the second test instance created by
`rgw_log_entry::generate_test_instances` is created using the default
constructor of `rgw_log_entry`. if any of the member variable is created
using random bits in the heap, there is chance that the test fails like:

2 rgw_log_entry
/tmp/typ-l5omDhmDf /tmp/typ-4aoRVkoiV differ: char 315, line 15
**** rgw_log_entry test 2 dump_json check failed ****
   ceph-dencoder type rgw_log_entry select_test 2 dump_json > /tmp/typ-l5omDhmDf
   ceph-dencoder type rgw_log_entry select_test 2 encode decode dump_json > /tmp/typ-4aoRVkoiV
15c15
<     "obj_size": 809908640,
---
>     "obj_size": 1122974112,

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/rgw/rgw_log.h

index dc3200f5f5160676b2778667b1e66d21ae58ff46..e8ac71cc053a150e3245adf6a96a9405b8a8dadd 100644 (file)
@@ -26,9 +26,9 @@ struct rgw_log_entry {
   string uri;
   string http_status;
   string error_code;
-  uint64_t bytes_sent;
-  uint64_t bytes_received;
-  uint64_t obj_size;
+  uint64_t bytes_sent = 0;
+  uint64_t bytes_received = 0;
+  uint64_t obj_size = 0;
   Clock::duration total_time{};
   string user_agent;
   string referrer;