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
This commit is contained in:
David James 2010-06-04 15:01:19 -07:00
parent e334840fb3
commit 3b3add5ad2
5 changed files with 20 additions and 20 deletions

View file

@ -125,14 +125,14 @@ void MetricsDaemon::Init(bool testing, MetricsLibraryInterface* metrics_lib) {
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 @@ DBusHandlerResult MetricsDaemon::MessageFilter(DBusConnection* connection,
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 {

View file

@ -583,7 +583,7 @@ TEST_F(MetricsDaemonTest, SetUserActiveStateTimeJump) {
EXPECT_TRUE(AssertNoOrEmptyUseRecordFile());
}
int main(int argc, char **argv) {
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View file

@ -20,12 +20,12 @@ static const char kUMAEventsPath[] =
"/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 @@ void MetricsLibrary::Init() {
}
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;

View file

@ -75,9 +75,9 @@ class MetricsLibrary : public MetricsLibraryInterface {
// 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_

View file

@ -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 @@ do
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 @@ END{
}
}"
exec awk "$program" /var/log/syslog
exec awk "$program" /var/log/syslog