Program: 198602
Project: 198602
Buggy source:
/** 
 * Dumps a human-readable summary of the battery statistics to the given PrintWriter.
 * @param pw a Printer to receive the dump output.
 */
@SuppressWarnings("String_Node_Str") public void dumpLocked(Context context,PrintWriter pw,int flags,int reqUid,long histStart){
  prepareForDumpLocked();
  final boolean filtering=(flags & (DUMP_HISTORY_ONLY | DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) != 0;
  if ((flags & DUMP_HISTORY_ONLY) != 0 || !filtering) {
    final long historyTotalSize=getHistoryTotalSize();
    final long historyUsedSize=getHistoryUsedSize();
    if (startIteratingHistoryLocked()) {
      try {
        pw.print("String_Node_Str");
        pw.print((100 * historyUsedSize) / historyTotalSize);
        pw.print("String_Node_Str");
        printSizeValue(pw,historyUsedSize);
        pw.print("String_Node_Str");
        printSizeValue(pw,historyTotalSize);
        pw.print("String_Node_Str");
        pw.print(getHistoryStringPoolSize());
        pw.print("String_Node_Str");
        printSizeValue(pw,getHistoryStringPoolBytes());
        pw.println("String_Node_Str");
        dumpHistoryLocked(pw,flags,histStart,false);
        pw.println();
      }
  finally {
        finishIteratingHistoryLocked();
      }
    }
    if (startIteratingOldHistoryLocked()) {
      try {
        final HistoryItem rec=new HistoryItem();
        pw.println("String_Node_Str");
        HistoryPrinter hprinter=new HistoryPrinter();
        long baseTime=-1;
        while (getNextOldHistoryLocked(rec)) {
          if (baseTime < 0) {
            baseTime=rec.time;
          }
          hprinter.printNextItem(pw,rec,baseTime,false,(flags & DUMP_VERBOSE) != 0);
        }
        pw.println();
      }
  finally {
        finishIteratingOldHistoryLocked();
      }
    }
  }
  if (filtering && (flags & (DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) == 0) {
    return;
  }
  if (!filtering) {
    SparseArray<? extends Uid> uidStats=getUidStats();
    final int NU=uidStats.size();
    boolean didPid=false;
    long nowRealtime=SystemClock.elapsedRealtime();
    for (int i=0; i < NU; i++) {
      Uid uid=uidStats.valueAt(i);
      SparseArray<? extends Uid.Pid> pids=uid.getPidStats();
      if (pids != null) {
        for (int j=0; j < pids.size(); j++) {
          Uid.Pid pid=pids.valueAt(j);
          if (!didPid) {
            pw.println("String_Node_Str");
            didPid=true;
          }
          long time=pid.mWakeSumMs + (pid.mWakeNesting > 0 ? (nowRealtime - pid.mWakeStartMs) : 0);
          pw.print("String_Node_Str");
          pw.print(pids.keyAt(j));
          pw.print("String_Node_Str");
          TimeUtils.formatDuration(time,pw);
          pw.println("String_Node_Str");
        }
      }
    }
    if (didPid) {
      pw.println();
    }
    if (dumpDurationSteps(pw,"String_Node_Str",getDischargeStepDurationsArray(),getNumDischargeStepDurations(),false)) {
      long timeRemaining=computeBatteryTimeRemaining(SystemClock.elapsedRealtime());
      if (timeRemaining >= 0) {
        pw.print("String_Node_Str");
        TimeUtils.formatDuration(timeRemaining / 1000,pw);
        pw.println();
      }
      pw.println();
    }
    if (dumpDurationSteps(pw,"String_Node_Str",getChargeStepDurationsArray(),getNumChargeStepDurations(),false)) {
      long timeRemaining=computeChargeTimeRemaining(SystemClock.elapsedRealtime());
      if (timeRemaining >= 0) {
        pw.print("String_Node_Str");
        TimeUtils.formatDuration(timeRemaining / 1000,pw);
        pw.println();
      }
      pw.println();
    }
  }
  if (!filtering || (flags & DUMP_CHARGED_ONLY) != 0) {
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + getStartCount() + "String_Node_Str"+ getIsOnBattery());
    dumpLocked(context,pw,"String_Node_Str",STATS_SINCE_CHARGED,reqUid);
    pw.println();
  }
  if (!filtering || (flags & DUMP_UNPLUGGED_ONLY) != 0) {
    pw.println("String_Node_Str");
    dumpLocked(context,pw,"String_Node_Str",STATS_SINCE_UNPLUGGED,reqUid);
  }
}

Fixed version (ground truth):
/** 
 * Dumps a human-readable summary of the battery statistics to the given PrintWriter.
 * @param pw a Printer to receive the dump output.
 */
@SuppressWarnings("String_Node_Str") public void dumpLocked(Context context,PrintWriter pw,int flags,int reqUid,long histStart){
  prepareForDumpLocked();
  final boolean filtering=(flags & (DUMP_HISTORY_ONLY | DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) != 0;
  if ((flags & DUMP_HISTORY_ONLY) != 0 || !filtering) {
    final long historyTotalSize=getHistoryTotalSize();
    final long historyUsedSize=getHistoryUsedSize();
    if (startIteratingHistoryLocked()) {
      try {
        pw.print("String_Node_Str");
        pw.print((100 * historyUsedSize) / historyTotalSize);
        pw.print("String_Node_Str");
        printSizeValue(pw,historyUsedSize);
        pw.print("String_Node_Str");
        printSizeValue(pw,historyTotalSize);
        pw.print("String_Node_Str");
        pw.print(getHistoryStringPoolSize());
        pw.print("String_Node_Str");
        printSizeValue(pw,getHistoryStringPoolBytes());
        pw.println("String_Node_Str");
        dumpHistoryLocked(pw,flags,histStart,false);
        pw.println();
      }
  finally {
        finishIteratingHistoryLocked();
      }
    }
    if (startIteratingOldHistoryLocked()) {
      try {
        final HistoryItem rec=new HistoryItem();
        pw.println("String_Node_Str");
        HistoryPrinter hprinter=new HistoryPrinter();
        long baseTime=-1;
        while (getNextOldHistoryLocked(rec)) {
          if (baseTime < 0) {
            baseTime=rec.time;
          }
          hprinter.printNextItem(pw,rec,baseTime,false,(flags & DUMP_VERBOSE) != 0);
        }
        pw.println();
      }
  finally {
        finishIteratingOldHistoryLocked();
      }
    }
  }
  if (filtering && (flags & (DUMP_UNPLUGGED_ONLY | DUMP_CHARGED_ONLY)) == 0) {
    return;
  }
  if (!filtering) {
    SparseArray<? extends Uid> uidStats=getUidStats();
    final int NU=uidStats.size();
    boolean didPid=false;
    long nowRealtime=SystemClock.elapsedRealtime();
    for (int i=0; i < NU; i++) {
      Uid uid=uidStats.valueAt(i);
      SparseArray<? extends Uid.Pid> pids=uid.getPidStats();
      if (pids != null) {
        for (int j=0; j < pids.size(); j++) {
          Uid.Pid pid=pids.valueAt(j);
          if (!didPid) {
            pw.println("String_Node_Str");
            didPid=true;
          }
          long time=pid.mWakeSumMs + (pid.mWakeNesting > 0 ? (nowRealtime - pid.mWakeStartMs) : 0);
          pw.print("String_Node_Str");
          pw.print(pids.keyAt(j));
          pw.print("String_Node_Str");
          TimeUtils.formatDuration(time,pw);
          pw.println("String_Node_Str");
        }
      }
    }
    if (didPid) {
      pw.println();
    }
  }
  if (!filtering || (flags & DUMP_CHARGED_ONLY) != 0) {
    if (dumpDurationSteps(pw,"String_Node_Str",getDischargeStepDurationsArray(),getNumDischargeStepDurations(),false)) {
      long timeRemaining=computeBatteryTimeRemaining(SystemClock.elapsedRealtime());
      if (timeRemaining >= 0) {
        pw.print("String_Node_Str");
        TimeUtils.formatDuration(timeRemaining / 1000,pw);
        pw.println();
      }
      pw.println();
    }
    if (dumpDurationSteps(pw,"String_Node_Str",getChargeStepDurationsArray(),getNumChargeStepDurations(),false)) {
      long timeRemaining=computeChargeTimeRemaining(SystemClock.elapsedRealtime());
      if (timeRemaining >= 0) {
        pw.print("String_Node_Str");
        TimeUtils.formatDuration(timeRemaining / 1000,pw);
        pw.println();
      }
      pw.println();
    }
    pw.println("String_Node_Str");
    pw.println("String_Node_Str" + getStartCount() + "String_Node_Str"+ getIsOnBattery());
    dumpLocked(context,pw,"String_Node_Str",STATS_SINCE_CHARGED,reqUid);
    pw.println();
  }
  if (!filtering || (flags & DUMP_UNPLUGGED_ONLY) != 0) {
    pw.println("String_Node_Str");
    dumpLocked(context,pw,"String_Node_Str",STATS_SINCE_UNPLUGGED,reqUid);
  }
}