crash-reporter: Fix coding style and cpplint issues. BUG=chromium:385849 TEST=`FEATURES=test emerge-$BOARD platform2` TEST=`cpplint.py --filter=--build/header_guard,-build/include_order *.h *.cc` Change-Id: I3c24dd9487df50cdb22fc1c7739c9e95e452afae Reviewed-on: https://chromium-review.googlesource.com/204487 Tested-by: Ben Chan <benchan@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Ben Chan <benchan@chromium.org>
diff --git a/chrome_collector.cc b/chrome_collector.cc index 7bf1f85..91a926b 100644 --- a/chrome_collector.cc +++ b/chrome_collector.cc
@@ -6,6 +6,7 @@ #include <glib.h> #include <pcrecpp.h> + #include <string> #include <vector> @@ -13,10 +14,10 @@ #include <base/logging.h> #include <base/strings/string_number_conversions.h> #include <base/strings/string_util.h> -#include "chromeos/process.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/dbus/dbus.h" -#include "chromeos/dbus/service_constants.h" +#include <chromeos/dbus/dbus.h> +#include <chromeos/dbus/service_constants.h> +#include <chromeos/process.h> +#include <chromeos/syslog_logging.h> const char kDefaultMinidumpName[] = "upload_file_minidump"; const char kTarPath[] = "/bin/tar"; @@ -125,7 +126,8 @@ return true; } -} //namespace + +} // namespace ChromeCollector::ChromeCollector() : output_file_ptr_(stdout) {} @@ -205,13 +207,13 @@ LOG(ERROR) << "Can't find : after name @ offset " << at; break; } - at += name.size() + 1; // Skip the name & : delimiter. + at += name.size() + 1; // Skip the name & : delimiter. if (!GetDelimitedString(data, ':', at, &size_string)) { LOG(ERROR) << "Can't find : after size @ offset " << at; break; } - at += size_string.size() + 1; // Skip the size & : delimiter. + at += size_string.size() + 1; // Skip the size & : delimiter. size_t size; if (!base::StringToSizeT(size_string, &size)) {
diff --git a/chrome_collector.h b/chrome_collector.h index c6dbfc9..3586d52 100644 --- a/chrome_collector.h +++ b/chrome_collector.h
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_CHROME_COLLECTOR_H_ -#define _CRASH_REPORTER_CHROME_COLLECTOR_H_ +#ifndef CRASH_REPORTER_CHROME_COLLECTOR_H_ +#define CRASH_REPORTER_CHROME_COLLECTOR_H_ #include <string> -#include "base/files/file_path.h" +#include <base/files/file_path.h> +#include <gtest/gtest_prod.h> // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST class SystemLogging; @@ -49,4 +50,4 @@ FILE *output_file_ptr_; }; -#endif +#endif // CRASH_REPORTER_CHROME_COLLECTOR_H_
diff --git a/chrome_collector_test.cc b/chrome_collector_test.cc index 9b97399..843ca8e 100644 --- a/chrome_collector_test.cc +++ b/chrome_collector_test.cc
@@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/chrome_collector.h" + #include <stdio.h> #include <dbus/dbus-glib-lowlevel.h> -#include "base/auto_reset.h" -#include "base/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/chrome_collector.h" -#include "gtest/gtest.h" +#include <base/auto_reset.h> +#include <base/file_util.h> +#include <base/files/scoped_temp_dir.h> +#include <chromeos/syslog_logging.h> +#include <chromeos/test_helpers.h> +#include <gtest/gtest.h> using base::FilePath;
diff --git a/crash_collector.cc b/crash_collector.cc index 8e463da..152aec3 100644 --- a/crash_collector.cc +++ b/crash_collector.cc
@@ -10,25 +10,26 @@ #include <sys/types.h> // for mode_t. #include <sys/wait.h> // For waitpid. #include <unistd.h> // For execv and fork. -#define __STDC_FORMAT_MACROS // PRId64 +#define __STDC_FORMAT_MACROS // PRId64 #include <inttypes.h> #include <set> +#include <utility> #include <vector> #include <dbus/dbus-glib-lowlevel.h> #include <glib.h> -#include "base/file_util.h" -#include "base/logging.h" -#include "base/posix/eintr_wrapper.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/cryptohome.h" -#include "chromeos/dbus/dbus.h" -#include "chromeos/dbus/service_constants.h" -#include "chromeos/process.h" +#include <base/file_util.h> +#include <base/logging.h> +#include <base/posix/eintr_wrapper.h> +#include <base/strings/string_split.h> +#include <base/strings/string_util.h> +#include <base/strings/stringprintf.h> +#include <chromeos/cryptohome.h> +#include <chromeos/dbus/dbus.h> +#include <chromeos/dbus/service_constants.h> +#include <chromeos/process.h> static const char kCollectChromeFile[] = "/mnt/stateful_partition/etc/collect_chrome_crashes";
diff --git a/crash_collector.h b/crash_collector.h index 67ff870..0e78661 100644 --- a/crash_collector.h +++ b/crash_collector.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_CRASH_COLLECTOR_H_ -#define _CRASH_REPORTER_CRASH_COLLECTOR_H_ +#ifndef CRASH_REPORTER_CRASH_COLLECTOR_H_ +#define CRASH_REPORTER_CRASH_COLLECTOR_H_ #include <sys/stat.h> @@ -12,8 +12,8 @@ #include <glib.h> -#include "base/files/file_path.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST +#include <base/files/file_path.h> +#include <gtest/gtest_prod.h> // for FRIEND_TEST // User crash collector. class CrashCollector { @@ -172,4 +172,4 @@ base::FilePath log_config_path_; }; -#endif // _CRASH_REPORTER_CRASH_COLLECTOR_H_ +#endif // CRASH_REPORTER_CRASH_COLLECTOR_H_
diff --git a/crash_collector_test.cc b/crash_collector_test.cc index 81a4a7c..1ffb8e4 100644 --- a/crash_collector_test.cc +++ b/crash_collector_test.cc
@@ -9,13 +9,14 @@ #include <dbus/dbus-glib-lowlevel.h> #include <glib.h> -#include "base/file_util.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" +#include <base/file_util.h> +#include <base/strings/string_util.h> +#include <base/strings/stringprintf.h> +#include <chromeos/syslog_logging.h> +#include <chromeos/test_helpers.h> +#include <gtest/gtest.h> + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest.h" using base::FilePath; using base::StringPrintf; @@ -115,12 +116,12 @@ EXPECT_EQ(kRootGid, directory_group); // No need to destroy the hash as GetCrashDirectoryInfo() will do it for us. - GHashTable *active_sessions = g_hash_table_new (g_str_hash, g_str_equal); + GHashTable *active_sessions = g_hash_table_new(g_str_hash, g_str_equal); char kUser[] = "chicken@butt.com"; char kHash[] = "hashcakes"; - g_hash_table_insert (active_sessions, - static_cast<gpointer>(kUser), - static_cast<gpointer>(kHash)); + g_hash_table_insert(active_sessions, + static_cast<gpointer>(kUser), + static_cast<gpointer>(kHash)); EXPECT_CALL(collector_, GetActiveUserSessions()) .WillOnce(Return(active_sessions));
diff --git a/crash_collector_test.h b/crash_collector_test.h index 71b42b7..28811b0 100644 --- a/crash_collector_test.h +++ b/crash_collector_test.h
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ -#define _CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ +#ifndef CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ +#define CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ #include "crash-reporter/crash_collector.h" @@ -14,7 +14,7 @@ class CrashCollectorMock : public CrashCollector { public: - MOCK_METHOD0(GetActiveUserSessions, GHashTable *()); + MOCK_METHOD0(GetActiveUserSessions, GHashTable*()); }; -#endif // _CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_ +#endif // CRASH_REPORTER_CRASH_COLLECTOR_TEST_H_
diff --git a/crash_reporter.cc b/crash_reporter.cc index be70ebc..8aafc46 100644 --- a/crash_reporter.cc +++ b/crash_reporter.cc
@@ -3,27 +3,27 @@ // found in the LICENSE file. #include <fcntl.h> // for open +#include <glib-object.h> #include <string> #include <vector> -#include <glib-object.h> - -#include <base/file_util.h> #include <base/command_line.h> +#include <base/file_util.h> #include <base/logging.h> #include <base/strings/string_split.h> #include <base/strings/string_util.h> #include <base/strings/stringprintf.h> -#include "chromeos/syslog_logging.h" +#include <chromeos/syslog_logging.h> +#include <gflags/gflags.h> +#include <metrics/metrics_library.h> + #include "crash-reporter/chrome_collector.h" #include "crash-reporter/kernel_collector.h" #include "crash-reporter/kernel_warning_collector.h" #include "crash-reporter/udev_collector.h" #include "crash-reporter/unclean_shutdown_collector.h" #include "crash-reporter/user_collector.h" -#include "gflags/gflags.h" -#include "metrics/metrics_library.h" #pragma GCC diagnostic ignored "-Wstrict-aliasing" DEFINE_bool(init, false, "Initialize crash logging"); @@ -252,7 +252,7 @@ // invalid fd. do { new_fd = open("/dev/null", 0); - CHECK(new_fd >= 0) << "Unable to open /dev/null"; + CHECK_GE(new_fd, 0) << "Unable to open /dev/null"; } while (new_fd >= 0 && new_fd <= 2); close(new_fd); }
diff --git a/kernel_collector.cc b/kernel_collector.cc index a57e587..2e93f2b 100644 --- a/kernel_collector.cc +++ b/kernel_collector.cc
@@ -4,10 +4,12 @@ #include "crash-reporter/kernel_collector.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" +#include <map> + +#include <base/file_util.h> +#include <base/logging.h> +#include <base/strings/string_util.h> +#include <base/strings/stringprintf.h> static const char kDefaultKernelStackSignature[] = "kernel-UnspecifiedStackSignature"; @@ -27,17 +29,17 @@ // Kernel log timestamp regular expression. static const std::string kTimestampRegex("^<.*>\\[\\s*(\\d+\\.\\d+)\\]"); -/* - * These regular expressions enable to us capture the PC in a backtrace. - * The backtrace is obtained through dmesg or the kernel's preserved/kcrashmem - * feature. - * - * For ARM we see: - * "<5>[ 39.458982] PC is at write_breakme+0xd0/0x1b4" - * For x86: - * "<0>[ 37.474699] EIP: [<790ed488>] write_breakme+0x80/0x108 \ - * SS:ESP 0068:e9dd3efc - */ +// +// These regular expressions enable to us capture the PC in a backtrace. +// The backtrace is obtained through dmesg or the kernel's preserved/kcrashmem +// feature. +// +// For ARM we see: +// "<5>[ 39.458982] PC is at write_breakme+0xd0/0x1b4" +// For x86: +// "<0>[ 37.474699] EIP: [<790ed488>] write_breakme+0x80/0x108 +// SS:ESP 0068:e9dd3efc" +// static const char *s_pc_regex[] = { 0, " PC is at ([^\\+ ]+).*", @@ -85,7 +87,7 @@ return false; } - if (record_re.FullMatch(record, &captured)){ + if (record_re.FullMatch(record, &captured)) { // Found a match, append it to the content, and remove from pstore. contents->append(captured); base::DeleteFile(ramoops_record, false); @@ -231,8 +233,7 @@ s_pc_regex[arch_] == NULL) { LOG(WARNING) << "KernelCollector does not understand this architecture"; return false; - } - else { + } else { FilePath ramoops_record; GetRamoopsRecordPath(&ramoops_record, 0); if (!base::PathExists(ramoops_record)) { @@ -349,8 +350,7 @@ } } -enum KernelCollector::ArchKind KernelCollector::GetCompilerArch(void) -{ +enum KernelCollector::ArchKind KernelCollector::GetCompilerArch(void) { #if defined(COMPILER_GCC) && defined(ARCH_CPU_ARM_FAMILY) return archArm; #elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_64) @@ -362,8 +362,7 @@ #endif } -void KernelCollector::SetArch(enum ArchKind arch) -{ +void KernelCollector::SetArch(enum ArchKind arch) { arch_ = arch; }
diff --git a/kernel_collector.h b/kernel_collector.h index c965cd3..8f52e44 100644 --- a/kernel_collector.h +++ b/kernel_collector.h
@@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_KERNEL_COLLECTOR_H_ -#define _CRASH_REPORTER_KERNEL_COLLECTOR_H_ +#ifndef CRASH_REPORTER_KERNEL_COLLECTOR_H_ +#define CRASH_REPORTER_KERNEL_COLLECTOR_H_ #include <pcrecpp.h> #include <string> -#include "base/files/file_path.h" +#include <base/files/file_path.h> +#include <gtest/gtest_prod.h> // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST // Kernel crash collector. class KernelCollector : public CrashCollector { @@ -103,4 +104,4 @@ enum ArchKind arch_; }; -#endif // _CRASH_REPORTER_KERNEL_COLLECTOR_H_ +#endif // CRASH_REPORTER_KERNEL_COLLECTOR_H_
diff --git a/kernel_collector_test.cc b/kernel_collector_test.cc index 5e9bc15..2644891 100644 --- a/kernel_collector_test.cc +++ b/kernel_collector_test.cc
@@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/kernel_collector.h" + #include <unistd.h> -#include "base/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/kernel_collector.h" -#include "gtest/gtest.h" +#include <base/file_util.h> +#include <base/files/scoped_temp_dir.h> +#include <base/strings/string_util.h> +#include <base/strings/stringprintf.h> +#include <chromeos/syslog_logging.h> +#include <chromeos/test_helpers.h> +#include <gtest/gtest.h> static int s_crashes = 0; static bool s_metrics = false; @@ -280,7 +281,6 @@ std::string contents; ASSERT_TRUE(base::ReadFileToString(FilePath(filename), &contents)); ASSERT_EQ("something", contents); - } // Perform tests which are common across architectures
diff --git a/kernel_warning_collector.cc b/kernel_warning_collector.cc index a186e9f..7082569 100644 --- a/kernel_warning_collector.cc +++ b/kernel_warning_collector.cc
@@ -4,11 +4,11 @@ #include "crash-reporter/kernel_warning_collector.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" +#include <base/file_util.h> +#include <base/logging.h> +#include <base/strings/string_number_conversions.h> +#include <base/strings/string_util.h> +#include <base/strings/stringprintf.h> namespace { const char kExecName[] = "kernel-warning"; @@ -34,7 +34,7 @@ LOG(ERROR) << "Could not open " << kKernelWarningPath; return false; } - /* The signature is in the first line. */ + // The signature is in the first line. std::string::size_type end_position = content->find('\n'); if (end_position == std::string::npos) { LOG(ERROR) << "unexpected kernel warning format";
diff --git a/kernel_warning_collector.h b/kernel_warning_collector.h index 7a50416..2559d72 100644 --- a/kernel_warning_collector.h +++ b/kernel_warning_collector.h
@@ -2,11 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ -#define _CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ +#ifndef CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ +#define CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ + +#include <string> #include <gtest/gtest_prod.h> // for FRIEND_TEST -#include <string> #include "crash-reporter/crash_collector.h" @@ -28,4 +29,4 @@ bool LoadKernelWarning(std::string *content, std::string *signature); }; -#endif // _CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_ +#endif // CRASH_REPORTER_KERNEL_WARNING_COLLECTOR_H_
diff --git a/list_proxies.cc b/list_proxies.cc index 41dd390..2e80e47 100644 --- a/list_proxies.cc +++ b/list_proxies.cc
@@ -3,21 +3,20 @@ // found in the LICENSE file. #include <unistd.h> // for isatty() +#include <dbus/dbus-glib-lowlevel.h> +#include <glib.h> #include <deque> #include <string> -#include <dbus/dbus-glib-lowlevel.h> -#include <glib.h> - -#include "base/command_line.h" -#include "base/file_util.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "base/strings/string_tokenizer.h" -#include "base/values.h" -#include "chromeos/dbus/dbus.h" -#include "chromeos/syslog_logging.h" +#include <base/command_line.h> +#include <base/file_util.h> +#include <base/strings/string_number_conversions.h> +#include <base/strings/string_tokenizer.h> +#include <base/strings/string_util.h> +#include <base/values.h> +#include <chromeos/dbus/dbus.h> +#include <chromeos/syslog_logging.h> const char kLibCrosProxyResolveSignalInterface[] = "org.chromium.CrashReporterLibcrosProxyResolvedInterface";
diff --git a/udev_collector.cc b/udev_collector.cc index 504f90e..5065527 100644 --- a/udev_collector.cc +++ b/udev_collector.cc
@@ -4,12 +4,16 @@ #include "crash-reporter/udev_collector.h" -#include "base/basictypes.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "chromeos/process.h" +#include <map> +#include <utility> +#include <vector> + +#include <base/basictypes.h> +#include <base/file_util.h> +#include <base/logging.h> +#include <base/strings/string_split.h> +#include <base/strings/string_util.h> +#include <chromeos/process.h> static const char kCollectUdevSignature[] = "crash_reporter-udev-collection"; static const char kGzipPath[] = "/bin/gzip";
diff --git a/udev_collector.h b/udev_collector.h index 0976d3e..e54ce5b 100644 --- a/udev_collector.h +++ b/udev_collector.h
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_UDEV_COLLECTOR_H_ -#define _CRASH_REPORTER_UDEV_COLLECTOR_H_ +#ifndef CRASH_REPORTER_UDEV_COLLECTOR_H_ +#define CRASH_REPORTER_UDEV_COLLECTOR_H_ #include <string> -#include "base/files/file_path.h" +#include <base/files/file_path.h> +#include <gtest/gtest_prod.h> // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST // Udev crash collector. class UdevCollector : public CrashCollector { @@ -22,7 +23,7 @@ // "ACTION=[action]:KERNEL=[name]:SUBSYSTEM=[subsystem]" // The values don't have to be in any particular order. One or more of them // could be omitted, in which case it would be treated as a wildcard (*). - bool HandleCrash(const std::string &udev_event); + bool HandleCrash(const std::string& udev_event); private: friend class UdevCollectorTest; @@ -33,4 +34,4 @@ } }; -#endif // _CRASH_REPORTER_UDEV_COLLECTOR_H_ +#endif // CRASH_REPORTER_UDEV_COLLECTOR_H_
diff --git a/udev_collector_test.cc b/udev_collector_test.cc index d5d6f29..b45fdd8 100644 --- a/udev_collector_test.cc +++ b/udev_collector_test.cc
@@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/file_util.h" -#include "base/files/file_enumerator.h" -#include "base/files/scoped_temp_dir.h" -#include "chromeos/test_helpers.h" +#include <base/file_util.h> +#include <base/files/file_enumerator.h> +#include <base/files/scoped_temp_dir.h> +#include <chromeos/test_helpers.h> +#include <gtest/gtest.h> + #include "crash-reporter/udev_collector.h" -#include "gtest/gtest.h" using base::FilePath;
diff --git a/unclean_shutdown_collector.cc b/unclean_shutdown_collector.cc index 8ee83c8..3c8af62 100644 --- a/unclean_shutdown_collector.cc +++ b/unclean_shutdown_collector.cc
@@ -4,8 +4,8 @@ #include "crash-reporter/unclean_shutdown_collector.h" -#include "base/file_util.h" -#include "base/logging.h" +#include <base/file_util.h> +#include <base/logging.h> static const char kUncleanShutdownFile[] = "/var/lib/crash_reporter/pending_clean_shutdown";
diff --git a/unclean_shutdown_collector.h b/unclean_shutdown_collector.h index ec21b7c..6324bc3 100644 --- a/unclean_shutdown_collector.h +++ b/unclean_shutdown_collector.h
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ -#define _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ +#ifndef CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ +#define CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ #include <string> -#include "base/files/file_path.h" +#include <base/files/file_path.h> +#include <gtest/gtest_prod.h> // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST // Unclean shutdown collector. class UncleanShutdownCollector : public CrashCollector { @@ -43,4 +44,4 @@ base::FilePath powerd_suspended_file_; }; -#endif // _CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_ +#endif // CRASH_REPORTER_UNCLEAN_SHUTDOWN_COLLECTOR_H_
diff --git a/unclean_shutdown_collector_test.cc b/unclean_shutdown_collector_test.cc index a0eec1c..d44ec0d 100644 --- a/unclean_shutdown_collector_test.cc +++ b/unclean_shutdown_collector_test.cc
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/unclean_shutdown_collector.h" + #include <unistd.h> -#include "base/file_util.h" -#include "base/strings/string_util.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/unclean_shutdown_collector.h" -#include "gtest/gtest.h" +#include <base/file_util.h> +#include <base/strings/string_util.h> +#include <chromeos/syslog_logging.h> +#include <chromeos/test_helpers.h> +#include <gtest/gtest.h> static int s_crashes = 0; static bool s_metrics = true;
diff --git a/user_collector.cc b/user_collector.cc index 3355b0e..198a43b 100644 --- a/user_collector.cc +++ b/user_collector.cc
@@ -12,19 +12,20 @@ #include <pwd.h> // For struct passwd. #include <sys/types.h> // For getpwuid_r, getgrnam_r, WEXITSTATUS. +#include <set> #include <string> #include <vector> -#include "base/file_util.h" -#include "base/logging.h" -#include "base/posix/eintr_wrapper.h" -#include "base/stl_util.h" -#include "base/strings/string_split.h" -#include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" -#include "chromeos/process.h" -#include "chromeos/syslog_logging.h" -#include "gflags/gflags.h" +#include <base/file_util.h> +#include <base/logging.h> +#include <base/posix/eintr_wrapper.h> +#include <base/stl_util.h> +#include <base/strings/string_split.h> +#include <base/strings/string_util.h> +#include <base/strings/stringprintf.h> +#include <chromeos/process.h> +#include <chromeos/syslog_logging.h> +#include <gflags/gflags.h> #pragma GCC diagnostic ignored "-Wstrict-aliasing" DEFINE_bool(core2md_failure, false, "Core2md failure test"); @@ -440,7 +441,7 @@ // Directory like /tmp/crash_reporter/1234 which contains the // procfs entries and other temporary files used during conversion. - FilePath container_dir(StringPrintf("/tmp/crash_reporter/%d", (int)pid)); + FilePath container_dir(StringPrintf("/tmp/crash_reporter/%d", pid)); // Delete a pre-existing directory from crash reporter that may have // been left around for diagnostics from a failed conversion attempt. // If we don't, existing files can cause forking to fail. @@ -495,19 +496,19 @@ kernel_supplied_name); } -/* Returns true if the given executable name matches that of Chrome. This - * includes checks for threads that Chrome has renamed. */ +// Returns true if the given executable name matches that of Chrome. This +// includes checks for threads that Chrome has renamed. static bool IsChromeExecName(const std::string &exec) { static const char *kChromeNames[] = { "chrome", - /* These are additional thread names seen in http://crash/ */ + // These are additional thread names seen in http://crash/ "MediaPipeline", - /* These come from the use of base::PlatformThread::SetName() directly */ + // These come from the use of base::PlatformThread::SetName() directly "CrBrowserMain", "CrRendererMain", "CrUtilityMain", "CrPPAPIMain", "CrPPAPIBrokerMain", "CrPluginMain", "CrWorkerMain", "CrGpuMain", "BrokerEvent", "CrVideoRenderer", "CrShutdownDetector", "UsbEventHandler", "CrNaClMain", "CrServiceMain", - /* These thread names come from the use of base::Thread */ + // These thread names come from the use of base::Thread "Gamepad polling thread", "Chrome_InProcGpuThread", "Chrome_DragDropThread", "Renderer::FILE", "VC manager", "VideoCaptureModuleImpl", "JavaBridge", "VideoCaptureManagerThread", @@ -536,29 +537,29 @@ "ServiceProcess_IO", "ServiceProcess_File", "extension_crash_uploader", "gpu-process_crash_uploader", "plugin_crash_uploader", "renderer_crash_uploader", - /* These come from the use of webkit_glue::WebThreadImpl */ + // These come from the use of webkit_glue::WebThreadImpl "Compositor", "Browser Compositor", // "WorkerPool/%d", // not easy to check because of "%d" - /* These come from the use of base::Watchdog */ + // These come from the use of base::Watchdog "Startup watchdog thread Watchdog", "Shutdown watchdog thread Watchdog", - /* These come from the use of AudioDeviceThread::Start */ + // These come from the use of AudioDeviceThread::Start "AudioDevice", "AudioInputDevice", "AudioOutputDevice", - /* These come from the use of MessageLoopFactory::GetMessageLoop */ + // These come from the use of MessageLoopFactory::GetMessageLoop "GpuVideoDecoder", "RtcVideoDecoderThread", "PipelineThread", "AudioDecoderThread", "VideoDecoderThread", - /* These come from the use of MessageLoopFactory::GetMessageLoopProxy */ + // These come from the use of MessageLoopFactory::GetMessageLoopProxy "CaptureVideoDecoderThread", "CaptureVideoDecoder", - /* These come from the use of base::SimpleThread */ + // These come from the use of base::SimpleThread "LocalInputMonitor/%d", // "%d" gets lopped off for kernel-supplied - /* These come from the use of base::DelegateSimpleThread */ + // These come from the use of base::DelegateSimpleThread "ipc_channel_nacl reader thread/%d", "plugin_audio_input_thread/%d", "plugin_audio_thread/%d", - /* These come from the use of base::SequencedWorkerPool */ + // These come from the use of base::SequencedWorkerPool "BrowserBlockingWorker%d/%d", // "%d" gets lopped off for kernel-supplied }; static std::set<std::string> chrome_names; - /* Initialize a set of chrome names, for efficient lookup */ + // Initialize a set of chrome names, for efficient lookup if (chrome_names.empty()) { for (size_t i = 0; i < arraysize(kChromeNames); i++) { std::string check_name(kChromeNames[i]);
diff --git a/user_collector.h b/user_collector.h index 6c82fa8..3658e51 100644 --- a/user_collector.h +++ b/user_collector.h
@@ -2,15 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef _CRASH_REPORTER_USER_COLLECTOR_H_ -#define _CRASH_REPORTER_USER_COLLECTOR_H_ +#ifndef CRASH_REPORTER_USER_COLLECTOR_H_ +#define CRASH_REPORTER_USER_COLLECTOR_H_ #include <string> #include <vector> -#include "base/files/file_path.h" +#include <base/files/file_path.h> +#include <gtest/gtest_prod.h> // for FRIEND_TEST + #include "crash-reporter/crash_collector.h" -#include "gtest/gtest_prod.h" // for FRIEND_TEST class SystemLogging; @@ -178,4 +179,4 @@ static const char *kGroupId; }; -#endif // _CRASH_REPORTER_USER_COLLECTOR_H_ +#endif // CRASH_REPORTER_USER_COLLECTOR_H_
diff --git a/user_collector_test.cc b/user_collector_test.cc index eeaf070..242c117 100644 --- a/user_collector_test.cc +++ b/user_collector_test.cc
@@ -2,17 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "crash-reporter/user_collector.h" + #include <bits/wordsize.h> #include <elf.h> #include <unistd.h> -#include "base/file_util.h" -#include "base/files/scoped_temp_dir.h" -#include "base/strings/string_split.h" -#include "chromeos/syslog_logging.h" -#include "chromeos/test_helpers.h" -#include "crash-reporter/user_collector.h" -#include "gtest/gtest.h" +#include <base/file_util.h> +#include <base/files/scoped_temp_dir.h> +#include <base/strings/string_split.h> +#include <chromeos/syslog_logging.h> +#include <chromeos/test_helpers.h> +#include <gtest/gtest.h> static int s_crashes = 0; static bool s_metrics = false;
diff --git a/warn_collector_test.c b/warn_collector_test.c index 76707b2..7e25d01 100644 --- a/warn_collector_test.c +++ b/warn_collector_test.c
@@ -8,8 +8,7 @@ */ #include <stdlib.h> -int main(int ac, char **av) -{ +int main(int ac, char **av) { int status = system("exec \"${SRC}\"/warn_collector_test.sh"); return status < 0 ? EXIT_FAILURE : WEXITSTATUS(status); }