From 2d451663befe303c8ea0af821babc02152c3c208 Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Mon, 27 Jul 2020 11:20:29 -0700 Subject: [PATCH] Cleanup for #inclusivefixit. Test: build Change-Id: If11a32c130367560394eccf442de95d941918073 --- fs_mgr/fs_mgr.cpp | 2 +- init/property_service.cpp | 2 +- .../test_kill_services/init_kill_services_test.cpp | 2 +- liblog/properties.cpp | 3 +-- logcat/logcat.cpp | 8 ++++---- logd/LogKlog.cpp | 14 +++++++------- .../property_info_serializer_test.cpp | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp index 0ae57870f..88bb2344c 100644 --- a/fs_mgr/fs_mgr.cpp +++ b/fs_mgr/fs_mgr.cpp @@ -607,7 +607,7 @@ static void tune_metadata_csum(const std::string& blk_device, const FstabEntry& LINFO << "Enabling ext4 metadata_csum on " << blk_device; - // requires to give last_fsck_time to current to avoid insane time. + // Must give `-T now` to prevent last_fsck_time from growing too large, // otherwise, tune2fs won't enable metadata_csum. const char* tune2fs_args[] = {TUNE2FS_BIN, "-O", "metadata_csum,64bit,extent", "-T", "now", blk_device.c_str()}; diff --git a/init/property_service.cpp b/init/property_service.cpp index 1fa33628b..a1e0969ed 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -994,7 +994,7 @@ void CreateSerializedPropertyInfo() { &property_infos)) { return; } - // Don't check for failure here, so we always have a sane list of properties. + // Don't check for failure here, since we don't always have all of these partitions. // E.g. In case of recovery, the vendor partition will not have mounted and we // still need the system / platform properties to function. if (access("/system_ext/etc/selinux/system_ext_property_contexts", R_OK) != -1) { diff --git a/init/test_kill_services/init_kill_services_test.cpp b/init/test_kill_services/init_kill_services_test.cpp index 7e543f232..66a332892 100644 --- a/init/test_kill_services/init_kill_services_test.cpp +++ b/init/test_kill_services/init_kill_services_test.cpp @@ -54,7 +54,7 @@ class InitKillServicesTest : public ::testing::TestWithParam {}; TEST_P(InitKillServicesTest, KillCriticalProcesses) { ExpectKillingServiceRecovers(GetParam()); - // sanity check init is still responding + // Ensure that init is still responding EXPECT_TRUE(SetProperty("test.death.test", "asdf")); EXPECT_EQ(GetProperty("test.death.test", ""), "asdf"); EXPECT_TRUE(SetProperty("test.death.test", "")); diff --git a/liblog/properties.cpp b/liblog/properties.cpp index 239211273..bb64008a7 100644 --- a/liblog/properties.cpp +++ b/liblog/properties.cpp @@ -456,7 +456,6 @@ bool __android_logger_property_get_bool(const char* key, int flag) { flag |= BOOL_DEFAULT_FLAG_SVELTE; } - /* Sanity Check */ if (flag & (BOOL_DEFAULT_FLAG_SVELTE | BOOL_DEFAULT_FLAG_ENG)) { flag &= ~BOOL_DEFAULT_FLAG_TRUE_FALSE; flag |= BOOL_DEFAULT_TRUE; @@ -613,4 +612,4 @@ int __android_log_is_debuggable() { return 1; } -#endif \ No newline at end of file +#endif diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index d15fa2be7..c7d16347b 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -616,15 +616,15 @@ int Logcat::Run(int argc, char** argv) { if (long_options[option_index].name == wrap_str) { mode |= ANDROID_LOG_WRAP | ANDROID_LOG_NONBLOCK; // ToDo: implement API that supports setting a wrap timeout - size_t dummy = ANDROID_LOG_WRAP_DEFAULT_TIMEOUT; - if (optarg && (!ParseUint(optarg, &dummy) || dummy < 1)) { + size_t timeout = ANDROID_LOG_WRAP_DEFAULT_TIMEOUT; + if (optarg && (!ParseUint(optarg, &timeout) || timeout < 1)) { error(EXIT_FAILURE, 0, "%s %s out of range.", long_options[option_index].name, optarg); } - if (dummy != ANDROID_LOG_WRAP_DEFAULT_TIMEOUT) { + if (timeout != ANDROID_LOG_WRAP_DEFAULT_TIMEOUT) { fprintf(stderr, "WARNING: %s %u seconds, ignoring %zu\n", long_options[option_index].name, ANDROID_LOG_WRAP_DEFAULT_TIMEOUT, - dummy); + timeout); } break; } diff --git a/logd/LogKlog.cpp b/logd/LogKlog.cpp index dbdf7fdd0..d6c7d2527 100644 --- a/logd/LogKlog.cpp +++ b/logd/LogKlog.cpp @@ -381,8 +381,8 @@ pid_t LogKlog::sniffPid(const char*& buf, ssize_t len) { } if ((i == 9) && (cp[i] == ' ')) { int pid = 0; - char dummy; - if (sscanf(cp + 4, "%d%c", &pid, &dummy) == 2) { + char placeholder; + if (sscanf(cp + 4, "%d%c", &pid, &placeholder) == 2) { buf = cp + 10; // skip-it-all return pid; } @@ -392,8 +392,8 @@ pid_t LogKlog::sniffPid(const char*& buf, ssize_t len) { // Mediatek kernels with modified printk if (*cp == '[') { int pid = 0; - char dummy; - if (sscanf(cp, "[%d:%*[a-z_./0-9:A-Z]]%c", &pid, &dummy) == 2) { + char placeholder; + if (sscanf(cp, "[%d:%*[a-z_./0-9:A-Z]]%c", &pid, &placeholder) == 2) { return pid; } break; // Only the first one @@ -703,7 +703,7 @@ int LogKlog::log(const char* buf, ssize_t len) { p = " "; b = 1; } - // paranoid sanity check, can not happen ... + // This shouldn't happen, but clamp the size if it does. if (b > LOGGER_ENTRY_MAX_PAYLOAD) { b = LOGGER_ENTRY_MAX_PAYLOAD; } @@ -712,7 +712,7 @@ int LogKlog::log(const char* buf, ssize_t len) { } // calculate buffer copy requirements ssize_t n = 1 + taglen + 1 + b + 1; - // paranoid sanity check, first two just can not happen ... + // Extra checks for likely impossible cases. if ((taglen > n) || (b > n) || (n > (ssize_t)USHRT_MAX) || (n <= 0)) { return -EINVAL; } @@ -722,7 +722,7 @@ int LogKlog::log(const char* buf, ssize_t len) { // If we malloc'd this buffer, we could get away without n's USHRT_MAX // test above, but we would then required a max(n, USHRT_MAX) as // truncating length argument to logbuf->log() below. Gain is protection - // of stack sanity and speedup, loss is truncated long-line content. + // against stack corruption and speedup, loss is truncated long-line content. char newstr[n]; char* np = newstr; diff --git a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp index a64306280..3907413cc 100644 --- a/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp +++ b/property_service/libpropertyinfoserializer/property_info_serializer_test.cpp @@ -139,7 +139,7 @@ TEST(propertyinfoserializer, GetPropertyInfo) { auto property_info_area = reinterpret_cast(serialized_trie.data()); - // Sanity check + // Smoke test auto root_node = property_info_area->root_node(); EXPECT_STREQ("root", root_node.name()); EXPECT_STREQ("default", property_info_area->context(root_node.context_index()));