added .clangd config file. initialized uninitialized variables
Test: tested compilation.
Change-Id: Iccb3ec4dd7ec6a631447c1e3a9e25d287362850f
diff --git a/.clangd b/.clangd
new file mode 100644
index 0000000..cf07f21
--- /dev/null
+++ b/.clangd
@@ -0,0 +1,10 @@
+Diagnostics:
+ ClangTidy:
+ # Add: [modernize-*, google-*, android-*, cppcoreguidelines-*]
+ Add:
+ - cppcoreguidelines-init-variables
+ - cppcoreguidelines-pro-type-member-init
+ Remove:
+ - modernize-use-trailing-return-type
+ - modernize-replace-disallow-copy-and-assign-macro
+ - cppcoreguidelines-pro-type-reinterpret-cast
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 4faae08..d085918 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -21,6 +21,7 @@
#include <memory>
#include <ostream>
#include <utility>
+#include <vector>
#include <android-base/properties.h>
#include <android-base/unique_fd.h>
@@ -33,9 +34,9 @@
#include <log/log_safetynet.h>
#include "update_engine/aosp/cleanup_previous_update_action.h"
+#include "update_engine/common/clock.h"
#include "update_engine/common/constants.h"
#include "update_engine/common/daemon_state_interface.h"
-#include "update_engine/common/clock.h"
#include "update_engine/common/download_action.h"
#include "update_engine/common/error_code_utils.h"
#include "update_engine/common/file_fetcher.h"
@@ -468,7 +469,7 @@
FROM_HERE,
"Failed to read payload header from " + metadata_filename);
}
- ErrorCode errorcode;
+ ErrorCode errorcode{};
PayloadMetadata payload_metadata;
if (payload_metadata.ParsePayloadHeader(metadata, &errorcode) !=
MetadataParseResult::kSuccess) {
@@ -527,7 +528,7 @@
VerifyPayloadParseManifest(metadata_filename, &manifest, error));
FileDescriptorPtr fd(new EintrSafeFileDescriptor);
- ErrorCode errorcode;
+ ErrorCode errorcode{};
BootControlInterface::Slot current_slot = GetCurrentSlot();
for (const PartitionUpdate& partition : manifest.partitions()) {
@@ -1190,7 +1191,7 @@
CHECK_NE(install_plan_.source_slot, UINT32_MAX);
CHECK_NE(install_plan_.target_slot, UINT32_MAX);
- ErrorCode error_code;
+ ErrorCode error_code{};
if (!install_plan_.ParsePartitions(manifest.partitions(),
boot_control_,
manifest.block_size(),
diff --git a/download_action.cc b/download_action.cc
index 0358569..ab86a7e 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -106,7 +106,7 @@
return false;
}
- ErrorCode error;
+ ErrorCode error{};
const bool success =
delta_performer_->Write(
cached_manifest_bytes.data(), cached_manifest_bytes.size(), &error) &&
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index 4737b46..b8d11f5 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -166,7 +166,7 @@
curl_handle_, CURLOPT_PROXY, GetCurrentProxy().c_str()),
CURLE_OK);
// Curl seems to require us to set the protocol
- curl_proxytype type;
+ curl_proxytype type{};
if (GetProxyType(GetCurrentProxy(), &type)) {
CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_PROXYTYPE, type),
CURLE_OK);
@@ -597,7 +597,7 @@
sent_byte_ = true;
{
- double transfer_size_double;
+ double transfer_size_double{};
CHECK_EQ(curl_easy_getinfo(curl_handle_,
CURLINFO_CONTENT_LENGTH_DOWNLOAD,
&transfer_size_double),
@@ -827,7 +827,7 @@
// Repeated calls to |curl_multi_info_read| will return a new struct each
// time, until a NULL is returned as a signal that there is no more to get
// at this point.
- int msgs_in_queue;
+ int msgs_in_queue{};
CURLMsg* curl_msg =
curl_multi_info_read(curl_multi_handle_, &msgs_in_queue);
if (curl_msg == nullptr)
diff --git a/payload_consumer/delta_performer.cc b/payload_consumer/delta_performer.cc
index 45103e6..43a3b3c 100644
--- a/payload_consumer/delta_performer.cc
+++ b/payload_consumer/delta_performer.cc
@@ -567,7 +567,7 @@
base::TimeTicks op_start_time = base::TimeTicks::Now();
- bool op_result;
+ bool op_result{};
const string op_name = InstallOperationTypeName(op.type());
switch (op.type()) {
case InstallOperation::REPLACE:
@@ -1232,7 +1232,7 @@
interrupted_hash == update_check_response_hash))
return false;
- int64_t resumed_update_failures;
+ int64_t resumed_update_failures{};
// Note that storing this value is optional, but if it is there it should
// not be more than the limit.
if (prefs->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures) &&
@@ -1412,7 +1412,7 @@
total_bytes_received_ += buffer_offset_;
// Speculatively count the resume as a failure.
- int64_t resumed_update_failures;
+ int64_t resumed_update_failures{};
if (prefs_->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)) {
resumed_update_failures++;
} else {
diff --git a/payload_consumer/partition_writer.cc b/payload_consumer/partition_writer.cc
index 1fb929e..3432c89 100644
--- a/payload_consumer/partition_writer.cc
+++ b/payload_consumer/partition_writer.cc
@@ -160,7 +160,7 @@
// partial updates. Use the source size as the indicator.
target_path_ = install_part_.target_path;
- int err;
+ int err{};
int flags = O_RDWR;
if (!interactive_)