am a5746ce3: am b8d727ec: Merge "Use sscanf() for parsing tag values." into lmp-dev
* commit 'a5746ce305bc331c4cb6a5bd1fa152c17813e0f8': Use sscanf() for parsing tag values.
This commit is contained in:
@@ -175,28 +175,34 @@ static int readNetworkStatsDetail(JNIEnv* env, jclass clazz, jobject stats,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Skip whitespace.
|
|
||||||
while (*pos == ' ') {
|
// Ignore whitespace
|
||||||
pos++;
|
while (*pos == ' ') pos++;
|
||||||
}
|
|
||||||
// Next field is tag.
|
// Find end of tag field
|
||||||
rawTag = strtoll(pos, &endPos, 16);
|
endPos = pos;
|
||||||
//ALOGI("Index #%d: %s", idx, buffer);
|
while (*endPos != ' ') endPos++;
|
||||||
if (pos == endPos) {
|
|
||||||
|
// Three digit field is always 0x0, otherwise parse
|
||||||
|
if (endPos - pos == 3) {
|
||||||
|
rawTag = 0;
|
||||||
|
} else {
|
||||||
|
if (sscanf(pos, "%llx", &rawTag) != 1) {
|
||||||
ALOGE("bad tag: %s", pos);
|
ALOGE("bad tag: %s", pos);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
s.tag = rawTag >> 32;
|
s.tag = rawTag >> 32;
|
||||||
if (limitTag != -1 && s.tag != limitTag) {
|
if (limitTag != -1 && s.tag != limitTag) {
|
||||||
//ALOGI("skipping due to tag: %s", buffer);
|
//ALOGI("skipping due to tag: %s", buffer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pos = endPos;
|
pos = endPos;
|
||||||
// Skip whitespace.
|
|
||||||
while (*pos == ' ') {
|
// Ignore whitespace
|
||||||
pos++;
|
while (*pos == ' ') pos++;
|
||||||
}
|
|
||||||
// Parse remaining fields.
|
// Parse remaining fields.
|
||||||
if (sscanf(pos, "%u %u %llu %llu %llu %llu",
|
if (sscanf(pos, "%u %u %llu %llu %llu %llu",
|
||||||
&s.uid, &s.set, &s.rxBytes, &s.rxPackets,
|
&s.uid, &s.set, &s.rxBytes, &s.rxPackets,
|
||||||
|
|||||||
Reference in New Issue
Block a user