From 91878b1c67799f85cb2bd6af36684b043f4651ce Mon Sep 17 00:00:00 2001 From: Emma Zhu Date: Mon, 6 May 2019 10:19:57 +0800 Subject: [PATCH] Refine initialization. --- Microsoft.WindowsAzure.Storage/includes/was/blob.h | 4 ++++ Microsoft.WindowsAzure.Storage/includes/was/common.h | 6 +++--- Microsoft.WindowsAzure.Storage/includes/was/core.h | 6 ++++-- .../includes/wascore/executor.h | 2 +- .../includes/wascore/streams.h | 2 +- .../includes/wascore/xmlhelpers.h | 5 +++++ Microsoft.WindowsAzure.Storage/src/timer_handler.cpp | 12 ++++++++++++ Microsoft.WindowsAzure.Storage/src/xml_wrapper.cpp | 9 +++++++-- Microsoft.WindowsAzure.Storage/src/xmlhelpers.cpp | 3 ++- 9 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Microsoft.WindowsAzure.Storage/includes/was/blob.h b/Microsoft.WindowsAzure.Storage/includes/was/blob.h index f7c6725c..36993589 100644 --- a/Microsoft.WindowsAzure.Storage/includes/was/blob.h +++ b/Microsoft.WindowsAzure.Storage/includes/was/blob.h @@ -1251,6 +1251,10 @@ namespace azure { namespace storage { m_server_encrypted(false), m_is_incremental_copy(false) { + m_standard_blob_tier = azure::storage::standard_blob_tier::unknown; + m_premium_blob_tier = azure::storage::premium_blob_tier::unknown; + m_archive_status = azure::storage::archive_status::unknown; + m_access_tier_inferred = false; } #if defined(_MSC_VER) && _MSC_VER < 1900 diff --git a/Microsoft.WindowsAzure.Storage/includes/was/common.h b/Microsoft.WindowsAzure.Storage/includes/was/common.h index d5595760..40539b48 100644 --- a/Microsoft.WindowsAzure.Storage/includes/was/common.h +++ b/Microsoft.WindowsAzure.Storage/includes/was/common.h @@ -808,7 +808,7 @@ namespace azure { namespace storage { /// Initializes a new instance of the class. /// metrics_properties() - : m_include_apis(false), m_retention_enabled(false), m_retention_days(0) + : m_enabled(false), m_include_apis(false), m_retention_enabled(false), m_retention_days(0) { } @@ -953,7 +953,7 @@ namespace azure { namespace storage { /// /// Initializes a new instance of the class. /// - cors_rule() + cors_rule() : m_max_age(0) { } @@ -1736,7 +1736,7 @@ namespace azure { namespace storage { web::http::http_headers m_user_headers; utility::datetime m_start_time; utility::datetime m_end_time; - client_log_level m_log_level; + client_log_level m_log_level = client_log_level::log_level_off; web::web_proxy m_proxy; std::vector m_request_results; pplx::extensibility::critical_section_t m_request_results_lock; diff --git a/Microsoft.WindowsAzure.Storage/includes/was/core.h b/Microsoft.WindowsAzure.Storage/includes/was/core.h index 078a0d7c..eeff33df 100644 --- a/Microsoft.WindowsAzure.Storage/includes/was/core.h +++ b/Microsoft.WindowsAzure.Storage/includes/was/core.h @@ -595,7 +595,8 @@ namespace azure { namespace storage { : m_is_response_available(false), m_target_location(storage_location::unspecified), m_http_status_code(0), - m_content_length(std::numeric_limits::max()) + m_content_length(std::numeric_limits::max()), + m_request_server_encrypted(false) { } @@ -610,7 +611,8 @@ namespace azure { namespace storage { m_target_location(target_location), m_end_time(utility::datetime::utc_now()), m_http_status_code(0), - m_content_length(std::numeric_limits::max()) + m_content_length(std::numeric_limits::max()), + m_request_server_encrypted(false) { } diff --git a/Microsoft.WindowsAzure.Storage/includes/wascore/executor.h b/Microsoft.WindowsAzure.Storage/includes/wascore/executor.h index 9f995a83..46f8bb72 100644 --- a/Microsoft.WindowsAzure.Storage/includes/wascore/executor.h +++ b/Microsoft.WindowsAzure.Storage/includes/wascore/executor.h @@ -160,7 +160,7 @@ namespace azure { namespace storage { namespace core { explicit storage_command_base(const storage_uri& request_uri, const pplx::cancellation_token& cancellation_token, const bool use_timeout, std::shared_ptr timer_handler) : m_request_uri(request_uri), m_location_mode(command_location_mode::primary_only), - m_cancellation_token(cancellation_token), m_use_timeout(use_timeout), m_timer_handler(timer_handler) + m_cancellation_token(cancellation_token), m_calculate_response_body_md5(false), m_use_timeout(use_timeout), m_timer_handler(timer_handler) { if (m_use_timeout) { diff --git a/Microsoft.WindowsAzure.Storage/includes/wascore/streams.h b/Microsoft.WindowsAzure.Storage/includes/wascore/streams.h index acc41273..ba204c92 100644 --- a/Microsoft.WindowsAzure.Storage/includes/wascore/streams.h +++ b/Microsoft.WindowsAzure.Storage/includes/wascore/streams.h @@ -56,7 +56,7 @@ namespace azure { namespace storage { namespace core { public: basic_cloud_ostreambuf() : basic_ostreambuf(), - m_current_streambuf_offset(0), m_committed(false) + m_current_streambuf_offset(0), m_committed(false), m_buffer_size(0), m_next_buffer_size(0) { } diff --git a/Microsoft.WindowsAzure.Storage/includes/wascore/xmlhelpers.h b/Microsoft.WindowsAzure.Storage/includes/wascore/xmlhelpers.h index 6bf52903..74d98aeb 100644 --- a/Microsoft.WindowsAzure.Storage/includes/wascore/xmlhelpers.h +++ b/Microsoft.WindowsAzure.Storage/includes/wascore/xmlhelpers.h @@ -207,7 +207,12 @@ class xml_writer virtual ~xml_writer() {} protected: + +#ifdef _WIN32 xml_writer() +#else // LINUX + xml_writer() :m_stream(nullptr) +#endif { } diff --git a/Microsoft.WindowsAzure.Storage/src/timer_handler.cpp b/Microsoft.WindowsAzure.Storage/src/timer_handler.cpp index 064b5b56..015e3b14 100644 --- a/Microsoft.WindowsAzure.Storage/src/timer_handler.cpp +++ b/Microsoft.WindowsAzure.Storage/src/timer_handler.cpp @@ -40,7 +40,19 @@ namespace azure { namespace storage { namespace core { { m_cancellation_token.deregister_callback(m_cancellation_token_registration); } + +#ifdef _WIN32 stop_timer(); +#else // LINUX + try + { + stop_timer(); + } + catch (boost::exception_detail::clone_impl > &e) + { + } +#endif + } void timer_handler::start_timer(const std::chrono::milliseconds& time) diff --git a/Microsoft.WindowsAzure.Storage/src/xml_wrapper.cpp b/Microsoft.WindowsAzure.Storage/src/xml_wrapper.cpp index 82cfec2a..5fcae4b7 100644 --- a/Microsoft.WindowsAzure.Storage/src/xml_wrapper.cpp +++ b/Microsoft.WindowsAzure.Storage/src/xml_wrapper.cpp @@ -66,20 +66,25 @@ bool xml_text_reader_wrapper::is_empty_element() std::string xml_text_reader_wrapper::get_local_name() { auto xml_char = xmlTextReaderLocalName(m_reader); - auto result = xml_char_to_string(xml_char); + std::string result; + if (xml_char != nullptr) { + result = xml_char_to_string(xml_char); xmlFree(xml_char); } + return result; } std::string xml_text_reader_wrapper::get_value() { auto xml_char = xmlTextReaderValue(m_reader); - auto result = xml_char_to_string(xml_char); + std::string result; + if (xml_char != nullptr) { + result = xml_char_to_string(xml_char); xmlFree(xml_char); } return result; diff --git a/Microsoft.WindowsAzure.Storage/src/xmlhelpers.cpp b/Microsoft.WindowsAzure.Storage/src/xmlhelpers.cpp index 09c0ee53..bcb2488e 100644 --- a/Microsoft.WindowsAzure.Storage/src/xmlhelpers.cpp +++ b/Microsoft.WindowsAzure.Storage/src/xmlhelpers.cpp @@ -355,7 +355,8 @@ namespace azure { namespace storage { namespace core { namespace xml { } #else // LINUX auto result = m_document->write_to_string(); - *m_stream << reinterpret_cast(result.c_str()); + if (m_stream != nullptr) + *m_stream << reinterpret_cast(result.c_str()); #endif }