summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/statsd/Android.mk4
-rw-r--r--cmds/statsd/src/FieldValue.cpp20
-rw-r--r--cmds/statsd/src/FieldValue.h21
-rw-r--r--cmds/statsd/src/HashableDimensionKey.cpp2
-rw-r--r--cmds/statsd/src/StatsLogProcessor.cpp2
-rw-r--r--cmds/statsd/src/StatsService.cpp2
-rw-r--r--cmds/statsd/src/guardrail/StatsdStats.cpp11
-rw-r--r--cmds/statsd/src/logd/LogEvent.cpp4
-rw-r--r--cmds/statsd/src/metrics/DurationMetricProducer.cpp5
-rw-r--r--cmds/statsd/src/metrics/GaugeMetricProducer.cpp1
-rw-r--r--cmds/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp1
-rw-r--r--cmds/statsd/src/stats_log_util.cpp10
12 files changed, 27 insertions, 56 deletions
diff --git a/cmds/statsd/Android.mk b/cmds/statsd/Android.mk
index 67b9089c8315..740fdc0af5f1 100644
--- a/cmds/statsd/Android.mk
+++ b/cmds/statsd/Android.mk
@@ -116,10 +116,8 @@ LOCAL_SRC_FILES := \
LOCAL_CFLAGS += \
-Wall \
+ -Wextra \
-Werror \
- -Wno-missing-field-initializers \
- -Wno-unused-variable \
- -Wno-unused-function \
-Wno-unused-parameter
ifeq (debug,)
diff --git a/cmds/statsd/src/FieldValue.cpp b/cmds/statsd/src/FieldValue.cpp
index 7b0b69a4bcae..6894bcf53e79 100644
--- a/cmds/statsd/src/FieldValue.cpp
+++ b/cmds/statsd/src/FieldValue.cpp
@@ -23,6 +23,23 @@ namespace android {
namespace os {
namespace statsd {
+int32_t getEncodedField(int32_t pos[], int32_t depth, bool includeDepth) {
+ int32_t field = 0;
+ for (int32_t i = 0; i <= depth; i++) {
+ int32_t shiftBits = 8 * (kMaxLogDepth - i);
+ field |= (pos[i] << shiftBits);
+ }
+
+ if (includeDepth) {
+ field |= (depth << 24);
+ }
+ return field;
+}
+
+int32_t encodeMatcherMask(int32_t mask[], int32_t depth) {
+ return getEncodedField(mask, depth, false) | 0xff000000;
+}
+
bool Field::matches(const Matcher& matcher) const {
if (mTag != matcher.mMatcher.getTag()) {
return false;
@@ -32,7 +49,7 @@ bool Field::matches(const Matcher& matcher) const {
}
return false;
-};
+}
void translateFieldMatcher(int tag, const FieldMatcher& matcher, int depth, int* pos, int* mask,
std::vector<Matcher>* output) {
@@ -71,7 +88,6 @@ void translateFieldMatcher(int tag, const FieldMatcher& matcher, int depth, int*
if (matcher.child_size() == 0) {
output->push_back(Matcher(Field(tag, pos, depth), encodeMatcherMask(mask, depth)));
- Matcher matcher = Matcher(Field(tag, pos, depth), encodeMatcherMask(mask, depth));
} else {
for (const auto& child : matcher.child()) {
translateFieldMatcher(tag, child, depth + 1, pos, mask, output);
diff --git a/cmds/statsd/src/FieldValue.h b/cmds/statsd/src/FieldValue.h
index 7484108d9e1a..d17dded8d691 100644
--- a/cmds/statsd/src/FieldValue.h
+++ b/cmds/statsd/src/FieldValue.h
@@ -33,29 +33,14 @@ const int32_t kClearLastBitDeco = 0x7f;
enum Type { INT, LONG, FLOAT, STRING };
+int32_t getEncodedField(int32_t pos[], int32_t depth, bool includeDepth);
-static int32_t getEncodedField(int32_t pos[], int32_t depth, bool includeDepth) {
- int32_t field = 0;
- for (int32_t i = 0; i <= depth; i++) {
- int32_t shiftBits = 8 * (kMaxLogDepth - i);
- field |= (pos[i] << shiftBits);
- }
-
- if (includeDepth) {
- field |= (depth << 24);
- }
- return field;
-}
-
-static int32_t encodeMatcherMask(int32_t mask[], int32_t depth) {
- return getEncodedField(mask, depth, false) | 0xff000000;
-}
+int32_t encodeMatcherMask(int32_t mask[], int32_t depth);
// Get the encoded field for a leaf with a [field] number at depth 0;
-static int32_t getSimpleField(size_t field) {
+inline int32_t getSimpleField(size_t field) {
return ((int32_t)field << 8 * 2);
}
-
/**
* Field is a wrapper class for 2 integers that represents the field of a log element in its Atom
* proto.
diff --git a/cmds/statsd/src/HashableDimensionKey.cpp b/cmds/statsd/src/HashableDimensionKey.cpp
index 68e2176c2e6d..d901bd669591 100644
--- a/cmds/statsd/src/HashableDimensionKey.cpp
+++ b/cmds/statsd/src/HashableDimensionKey.cpp
@@ -68,7 +68,6 @@ bool filterValues(const vector<Matcher>& matcherFields, const vector<FieldValue>
for (const auto& value : values) {
// TODO: potential optimization here to break early because all fields are naturally
// sorted.
- int32_t filteredField;
if (value.mField.matches(matcher)) {
matchedResults.push_back(FieldValue(
Field(value.mField.getTag(), (value.mField.getField() & matcher.mMask)),
@@ -148,7 +147,6 @@ void filterGaugeValues(const std::vector<Matcher>& matcherFields,
const std::vector<FieldValue>& values, std::vector<FieldValue>* output) {
for (const auto& field : matcherFields) {
for (const auto& value : values) {
- int filteredField;
if (value.mField.matches(field)) {
output->push_back(value);
}
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index afb2c4782fac..87dec5d1656d 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -58,7 +58,7 @@ const int FIELD_ID_REPORTS = 2;
const int FIELD_ID_UID = 1;
const int FIELD_ID_ID = 2;
// for ConfigMetricsReport
-const int FIELD_ID_METRICS = 1;
+// const int FIELD_ID_METRICS = 1; // written in MetricsManager.cpp
const int FIELD_ID_UID_MAP = 2;
const int FIELD_ID_LAST_REPORT_ELAPSED_NANOS = 3;
const int FIELD_ID_CURRENT_REPORT_ELAPSED_NANOS = 4;
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 18ada658e9d8..0a4e412bff20 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -124,8 +124,6 @@ void StatsService::init_build_type_callback(void* cookie, const char* /*name*/,
*/
status_t StatsService::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
uint32_t flags) {
- status_t err;
-
switch (code) {
case SHELL_COMMAND_TRANSACTION: {
int in = data.readFileDescriptor();
diff --git a/cmds/statsd/src/guardrail/StatsdStats.cpp b/cmds/statsd/src/guardrail/StatsdStats.cpp
index e2e94263ed8f..66cb1d04a4e1 100644
--- a/cmds/statsd/src/guardrail/StatsdStats.cpp
+++ b/cmds/statsd/src/guardrail/StatsdStats.cpp
@@ -45,18 +45,9 @@ const int FIELD_ID_CONFIG_STATS = 3;
const int FIELD_ID_ATOM_STATS = 7;
const int FIELD_ID_UIDMAP_STATS = 8;
const int FIELD_ID_ANOMALY_ALARM_STATS = 9;
-const int FIELD_ID_PULLED_ATOM_STATS = 10;
+// const int FIELD_ID_PULLED_ATOM_STATS = 10; // The proto is written in stats_log_util.cpp
const int FIELD_ID_LOGGER_ERROR_STATS = 11;
-const int FIELD_ID_MATCHER_STATS_NAME = 1;
-const int FIELD_ID_MATCHER_STATS_COUNT = 2;
-
-const int FIELD_ID_CONDITION_STATS_NAME = 1;
-const int FIELD_ID_CONDITION_STATS_COUNT = 2;
-
-const int FIELD_ID_METRIC_STATS_NAME = 1;
-const int FIELD_ID_METRIC_STATS_COUNT = 2;
-
const int FIELD_ID_ATOM_STATS_TAG = 1;
const int FIELD_ID_ATOM_STATS_COUNT = 2;
diff --git a/cmds/statsd/src/logd/LogEvent.cpp b/cmds/statsd/src/logd/LogEvent.cpp
index 7489d9b72e94..f07fc66dbcbb 100644
--- a/cmds/statsd/src/logd/LogEvent.cpp
+++ b/cmds/statsd/src/logd/LogEvent.cpp
@@ -178,10 +178,6 @@ bool LogEvent::write(const AttributionNode& node) {
void LogEvent::init(android_log_context context) {
android_log_list_element elem;
int i = 0;
-
- int seenListStart = 0;
-
- int32_t field = 0;
int depth = -1;
int pos[] = {1, 1, 1};
do {
diff --git a/cmds/statsd/src/metrics/DurationMetricProducer.cpp b/cmds/statsd/src/metrics/DurationMetricProducer.cpp
index af22578cc758..67d95dbd4cc5 100644
--- a/cmds/statsd/src/metrics/DurationMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/DurationMetricProducer.cpp
@@ -150,10 +150,9 @@ void DurationMetricProducer::onSlicedConditionMayChangeLocked(const uint64_t eve
std::unordered_set<HashableDimensionKey> conditionDimensionsKeySet;
- ConditionState conditionState = mWizard->getMetConditionDimension(
- mConditionTrackerIndex, mDimensionsInCondition, &conditionDimensionsKeySet);
+ mWizard->getMetConditionDimension(mConditionTrackerIndex, mDimensionsInCondition,
+ &conditionDimensionsKeySet);
- bool condition = (conditionState == ConditionState::kTrue);
for (auto& pair : mCurrentSlicedDurationTrackerMap) {
conditionDimensionsKeySet.erase(pair.first.getDimensionKeyInCondition());
}
diff --git a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
index af3b4c5a648a..8aa816938c0d 100644
--- a/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
+++ b/cmds/statsd/src/metrics/GaugeMetricProducer.cpp
@@ -334,7 +334,6 @@ void GaugeMetricProducer::onMatchedLogEventInternalLocked(
}
void GaugeMetricProducer::updateCurrentSlicedBucketForAnomaly() {
- status_t err = NO_ERROR;
for (const auto& slice : *mCurrentSlicedBucket) {
if (slice.second.empty()) {
continue;
diff --git a/cmds/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp b/cmds/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp
index c29876b5eae0..95df5ae6e8bd 100644
--- a/cmds/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp
+++ b/cmds/statsd/src/metrics/duration_helper/MaxDurationTracker.cpp
@@ -177,7 +177,6 @@ bool MaxDurationTracker::flushCurrentBucket(
false; // has either a kStarted or kPaused event across bucket boundaries
// meaning we need to carry them over to the new bucket.
for (auto it = mInfos.begin(); it != mInfos.end(); ++it) {
- int64_t finalDuration = it->second.lastDuration;
if (it->second.state == DurationState::kStopped) {
// No need to keep buckets for events that were stopped before.
mInfos.erase(it);
diff --git a/cmds/statsd/src/stats_log_util.cpp b/cmds/statsd/src/stats_log_util.cpp
index e73577041f75..f7b768f5f2b2 100644
--- a/cmds/statsd/src/stats_log_util.cpp
+++ b/cmds/statsd/src/stats_log_util.cpp
@@ -41,15 +41,12 @@ const int DIMENSIONS_VALUE_FIELD = 1;
const int DIMENSIONS_VALUE_VALUE_STR = 2;
const int DIMENSIONS_VALUE_VALUE_INT = 3;
const int DIMENSIONS_VALUE_VALUE_LONG = 4;
-const int DIMENSIONS_VALUE_VALUE_BOOL = 5;
+// const int DIMENSIONS_VALUE_VALUE_BOOL = 5; // logd doesn't have bool data type.
const int DIMENSIONS_VALUE_VALUE_FLOAT = 6;
const int DIMENSIONS_VALUE_VALUE_TUPLE = 7;
const int DIMENSIONS_VALUE_TUPLE_VALUE = 1;
-// for MessageValue Proto
-const int FIELD_ID_FIELD_VALUE_IN_MESSAGE_VALUE_PROTO = 1;
-
// for PulledAtomStats proto
const int FIELD_ID_PULLED_ATOM_STATS = 10;
const int FIELD_ID_PULL_ATOM_ID = 1;
@@ -131,11 +128,6 @@ void writeDimensionToProto(const HashableDimensionKey& dimension, ProtoOutputStr
protoOutput->end(topToken);
}
-// for Field Proto
-const int FIELD_FIELD = 1;
-const int FIELD_POSITION_INDEX = 2;
-const int FIELD_CHILD = 3;
-
// Supported Atoms format
// XYZ_Atom {
// repeated SubMsg field_1 = 1;