From: Kefu Chai Date: Thu, 26 Dec 2019 13:42:18 +0000 (+0800) Subject: rgw: initialize member variables of rgw_log_entry X-Git-Tag: v15.1.0~354^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F32430%2Fhead;p=ceph.git rgw: initialize member variables of rgw_log_entry `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 --- diff --git a/src/rgw/rgw_log.h b/src/rgw/rgw_log.h index dc3200f5f516..e8ac71cc053a 100644 --- a/src/rgw/rgw_log.h +++ b/src/rgw/rgw_log.h @@ -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;