Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a237e05c authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Use sscanf() for parsing tag values." into lmp-dev

parents d5dfb723 e47d5435
Loading
Loading
Loading
Loading
+21 −15
Original line number Diff line number Diff line
@@ -175,28 +175,34 @@ static int readNetworkStatsDetail(JNIEnv* env, jclass clazz, jobject stats,
                continue;
            }
        }
        // Skip whitespace.
        while (*pos == ' ') {
            pos++;
        }
        // Next field is tag.
        rawTag = strtoll(pos, &endPos, 16);
        //ALOGI("Index #%d: %s", idx, buffer);
        if (pos == endPos) {

        // Ignore whitespace
        while (*pos == ' ') pos++;

        // Find end of tag field
        endPos = pos;
        while (*endPos != ' ') 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);
                fclose(fp);
                return -1;
            }
        }
        s.tag = rawTag >> 32;
        if (limitTag != -1 && s.tag != limitTag) {
            //ALOGI("skipping due to tag: %s", buffer);
            continue;
        }
        pos = endPos;
        // Skip whitespace.
        while (*pos == ' ') {
            pos++;
        }

        // Ignore whitespace
        while (*pos == ' ') pos++;

        // Parse remaining fields.
        if (sscanf(pos, "%u %u %llu %llu %llu %llu",
                &s.uid, &s.set, &s.rxBytes, &s.rxPackets,