Cleanup style nits in metrics daemon.
- Remove trailing spaces.
- Convert 'char *' to 'char*'
- Fix other minor style nits
- Many of these issues were pointed out by tfarina.
BUG=none
TEST=Checked that it compiles and passes tests.
Review URL: http://codereview.chromium.org/2693001
diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc
index 523d8bd..04ad686 100644
--- a/metrics/metrics_daemon.cc
+++ b/metrics/metrics_daemon.cc
@@ -125,14 +125,14 @@
DBusError error;
dbus_error_init(&error);
- DBusConnection *connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ DBusConnection* connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
LOG_IF(FATAL, dbus_error_is_set(&error)) <<
"No D-Bus connection: " << SAFE_MESSAGE(error);
dbus_connection_setup_with_g_main(connection, NULL);
// Registers D-Bus matches for the signals we would like to catch.
- for (unsigned int m = 0; m < sizeof(kDBusMatches_) / sizeof(char *); m++) {
+ for (unsigned int m = 0; m < sizeof(kDBusMatches_) / sizeof(char*); m++) {
const char* match = kDBusMatches_[m];
DLOG(INFO) << "adding dbus match: " << match;
dbus_bus_add_match(connection, match, &error);
@@ -177,28 +177,28 @@
CHECK(strcmp(dbus_message_get_member(message),
"StateChanged") == 0);
- char *state_name;
+ char* state_name;
dbus_message_iter_get_basic(&iter, &state_name);
daemon->NetStateChanged(state_name, ticks);
} else if (strcmp(interface, DBUS_IFACE_POWER_MANAGER) == 0) {
CHECK(strcmp(dbus_message_get_member(message),
"PowerStateChanged") == 0);
- char *state_name;
+ char* state_name;
dbus_message_iter_get_basic(&iter, &state_name);
daemon->PowerStateChanged(state_name, now);
} else if (strcmp(interface, DBUS_IFACE_SCREENSAVER_MANAGER) == 0) {
CHECK(strcmp(dbus_message_get_member(message),
"LockStateChanged") == 0);
- char *state_name;
+ char* state_name;
dbus_message_iter_get_basic(&iter, &state_name);
daemon->ScreenSaverStateChanged(state_name, now);
} else if (strcmp(interface, DBUS_IFACE_SESSION_MANAGER) == 0) {
CHECK(strcmp(dbus_message_get_member(message),
"SessionStateChanged") == 0);
- char *state_name;
+ char* state_name;
dbus_message_iter_get_basic(&iter, &state_name);
daemon->SessionStateChanged(state_name, now);
} else {
diff --git a/metrics/metrics_daemon_test.cc b/metrics/metrics_daemon_test.cc
index 5614eed..31f079d 100644
--- a/metrics/metrics_daemon_test.cc
+++ b/metrics/metrics_daemon_test.cc
@@ -583,7 +583,7 @@
EXPECT_TRUE(AssertNoOrEmptyUseRecordFile());
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
diff --git a/metrics/metrics_library.cc b/metrics/metrics_library.cc
index 6ec7226..e4087ef 100644
--- a/metrics/metrics_library.cc
+++ b/metrics/metrics_library.cc
@@ -20,12 +20,12 @@
"/var/log/metrics/uma-events";
static const int32_t kBufferSize = 1024;
-using namespace std;
+using std::string;
// TODO(sosa@chromium.org) - use Chromium logger instead of stderr
static void PrintError(const char* message, const char* file,
int code) {
- static const char *kProgramName = "libmetrics";
+ static const char kProgramName[] = "libmetrics";
if (code == 0) {
fprintf(stderr, "%s: %s\n", kProgramName, message);
} else if (file == NULL) {
@@ -113,7 +113,7 @@
}
bool MetricsLibrary::SendToAutotest(const string& name, int value) {
- FILE *autotest_file = fopen(kAutotestPath, "a+");
+ FILE* autotest_file = fopen(kAutotestPath, "a+");
if (autotest_file == NULL) {
PrintError("fopen", kAutotestPath, errno);
return false;
diff --git a/metrics/metrics_library.h b/metrics/metrics_library.h
index 8ae3f5b..a9ac0bb 100644
--- a/metrics/metrics_library.h
+++ b/metrics/metrics_library.h
@@ -75,9 +75,9 @@
// message. The caller is responsible to store the \0 character
// between NAME and VALUE (e.g. "%s%c%d", name, '\0', value).
int32_t FormatChromeMessage(int32_t buffer_size, char* buffer,
- const char *format, ...);
+ const char* format, ...);
const char* uma_events_file_;
};
-#endif /* METRICS_LIBRARY_H_ */
+#endif // METRICS_LIBRARY_H_
diff --git a/metrics/syslog_parser.sh b/metrics/syslog_parser.sh
index 7f3003f..7d064be 100755
--- a/metrics/syslog_parser.sh
+++ b/metrics/syslog_parser.sh
@@ -12,7 +12,7 @@
# "Sectors" to METRIC_NAME for the two available measurements, uptime
# and number of sectors read thus far.
-# You will need to emit messages similar to the following in order to add a
+# You will need to emit messages similar to the following in order to add a
# a metric using this process. You will need to emit both a start and stop
# time and the metric reported will be the difference in values
@@ -36,25 +36,25 @@
if [ $first -eq 1 ]
then
first=0
- program_name=$m
+ program_name=$m
else
first=1
- metrics_name=$m
-
+ metrics_name=$m
+
# Example of line from /var/log/messages:
# Nov 15 08:05:42 localhost connmand[822]: start metric time 12 sectors 56
# "upstart:" is $5, 1234 is $9, etc.
program="${program}/$program_name([[0-9]+]:|:) start $metrics_name/\
{
metrics_start[\"${metrics_name}Time\"] = \$9;
- metrics_start[\"${metrics_name}Sectors\"] = \$11;
+ metrics_start[\"${metrics_name}Sectors\"] = \$11;
}"
program="${program}/$program_name([[0-9]+]:|:) stop $metrics_name/\
- {
+ {
metrics_stop[\"${metrics_name}Time\"] = \$9;
metrics_stop[\"${metrics_name}Sectors\"] = \$11;
}"
- fi
+ fi
done
# Do all the differencing here
@@ -66,4 +66,4 @@
}
}"
-exec awk "$program" /var/log/syslog
\ No newline at end of file
+exec awk "$program" /var/log/syslog