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

Commit 2b667cda authored by Ajay Panicker's avatar Ajay Panicker Committed by Andre Eisenbach
Browse files

Fix line wrapping for btsnooz

Change-Id: I4558c652577ffeb3f1ac4f273472ccf98d70924b
parent 7ee947c6
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -156,16 +156,18 @@ void btif_debug_btsnoop_dump(int fd) {
  uint8_t b64_in[3] = {0};
  char b64_out[5] = {0};

  size_t i = sizeof(btsnooz_preamble_t);
  size_t line_length = 0;
  while (ringbuffer_size(ringbuffer) > 0) {
    size_t read = ringbuffer_pop(ringbuffer, b64_in, 3);
    if (i > 0 && i % MAX_LINE_LENGTH == 0)
    if (line_length >= MAX_LINE_LENGTH) {
      dprintf(fd, "\n");
    i += b64_ntop(b64_in, read, b64_out, 5);
      line_length = 0;
    }
    line_length += b64_ntop(b64_in, read, b64_out, 5);
    dprintf(fd, "%s", b64_out);
  }

  dprintf(fd, "\n--- END:BTSNOOP_LOG_SUMMARY (%zu bytes out) ---\n", i);
  dprintf(fd, "\n--- END:BTSNOOP_LOG_SUMMARY ---\n");

error:
  ringbuffer_free(ringbuffer);