diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 51c201eeb..9a2625926 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -489,7 +489,7 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe int32 duration = 0; FileType file_type = FileType::Temp; - Result> r_inline_message; + Result> r_inline_message = Status::Error(500, "Uninited"); switch (input_result->get_id()) { case td_api::inputInlineQueryResultAnimatedGif::ID: { auto animated_gif = move_tl_object_as(input_result); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 0e495d89f..e214f0e69 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -16427,7 +16427,7 @@ Result MessagesManager::process_input_mess bool have_file = true; // TODO: send from secret chat to common - Result r_file_id; + Result r_file_id = Status::Error(500, "Have no file"); tl_object_ptr input_thumbnail; vector sticker_file_ids; switch (message_type) { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 99d42ee7d..798f48c78 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -7178,18 +7178,17 @@ td_api::object_ptr Td::do_static_request(td_api::parseTextEntiti return make_error(400, "Parse mode must be non-empty"); } - Result> r_entities; - switch (request.parse_mode_->get_id()) { - case td_api::textParseModeHTML::ID: - r_entities = parse_html(request.text_); - break; - case td_api::textParseModeMarkdown::ID: - r_entities = parse_markdown(request.text_); - break; - default: - UNREACHABLE(); - break; - } + auto r_entities = [&]() -> Result> { + switch (request.parse_mode_->get_id()) { + case td_api::textParseModeHTML::ID: + return parse_html(request.text_); + case td_api::textParseModeMarkdown::ID: + return parse_markdown(request.text_); + default: + UNREACHABLE(); + return Status::Error(500, "Unknown parse mode"); + } + }(); if (r_entities.is_error()) { return make_error(400, PSLICE() << "Can't parse entities: " << r_entities.error().message()); } diff --git a/td/telegram/files/FileUploader.cpp b/td/telegram/files/FileUploader.cpp index 0c5c83363..ff5b0e47b 100644 --- a/td/telegram/files/FileUploader.cpp +++ b/td/telegram/files/FileUploader.cpp @@ -275,12 +275,13 @@ Result FileUploader::process_part(Part part, NetQueryPtr net_query) { if (net_query->is_error()) { return std::move(net_query->error()); } - Result result; - if (big_flag_) { - result = fetch_result(net_query->ok()); - } else { - result = fetch_result(net_query->ok()); - } + Result result = [&] { + if (big_flag_) { + return fetch_result(net_query->ok()); + } else { + return fetch_result(net_query->ok()); + } + }(); if (result.is_error()) { return result.move_as_error(); } diff --git a/tdactor/td/actor/PromiseFuture.h b/tdactor/td/actor/PromiseFuture.h index d26c32b77..81af29e24 100644 --- a/tdactor/td/actor/PromiseFuture.h +++ b/tdactor/td/actor/PromiseFuture.h @@ -517,7 +517,7 @@ class FutureActor final : public Actor { private: EventFull event_; - Result result_; + Result result_ = Status::Error(500, "Empty FutureActor"); State state_; void set_value(T &&value) { diff --git a/tdnet/td/net/GetHostByNameActor.h b/tdnet/td/net/GetHostByNameActor.h index b352a05d1..dabed07f6 100644 --- a/tdnet/td/net/GetHostByNameActor.h +++ b/tdnet/td/net/GetHostByNameActor.h @@ -23,6 +23,9 @@ class GetHostByNameActor final : public td::Actor { struct Value { Result ip; double expire_at; + + Value(Result ip, double expire_at) : ip(std::move(ip)), expire_at(expire_at) { + } }; std::unordered_map cache_; static constexpr int32 CACHE_TIME = 60 * 29; // 29 minutes diff --git a/tdnet/td/net/HttpReader.cpp b/tdnet/td/net/HttpReader.cpp index 1cfa7666a..f67cbd5b8 100644 --- a/tdnet/td/net/HttpReader.cpp +++ b/tdnet/td/net/HttpReader.cpp @@ -610,19 +610,20 @@ Status HttpReader::parse_json_parameters(MutableSlice parameters) { return Status::Error(400, "Bad Request: can't parse object, ':' expected"); } parser.skip_whitespaces(); - Result r_value; - if (parser.peek_char() == '"') { - r_value = json_string_decode(parser); - } else { - const int32 DEFAULT_MAX_DEPTH = 100; - auto begin = parser.ptr(); - auto result = do_json_skip(parser, DEFAULT_MAX_DEPTH); - if (result.is_ok()) { - r_value = MutableSlice(begin, parser.ptr()); + auto r_value = [&]() -> Result { + if (parser.peek_char() == '"') { + return json_string_decode(parser); } else { - r_value = result.move_as_error(); + const int32 DEFAULT_MAX_DEPTH = 100; + auto begin = parser.ptr(); + auto result = do_json_skip(parser, DEFAULT_MAX_DEPTH); + if (result.is_ok()) { + return MutableSlice(begin, parser.ptr()); + } else { + return result.move_as_error(); + } } - } + }(); if (r_value.is_error()) { return Status::Error(400, string("Bad Request: can't parse parameter value: ") + r_value.error().message().c_str());