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

Commit 17333175 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Remove dead code - dump_bin

Bug: 68359837
Test: compilation test
Change-Id: I7a3e9ee79da06753b329fcd13c6c8aa76bd6fa8f
parent 925f621f
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@

#include <stdint.h>

void dump_bin(const char* title, const char* data, int size);

int sock_send_fd(int sock_fd, const uint8_t* buffer, int len, int send_fd);
int sock_send_all(int sock_fd, const uint8_t* buf, int len);
int sock_recv_all(int sock_fd, uint8_t* buf, int len);
+0 −86
Original line number Diff line number Diff line
@@ -145,89 +145,3 @@ int sock_send_fd(int sock_fd, const uint8_t* buf, int len, int send_fd) {
  close(send_fd);
  return ret_len;
}

static const char* hex_table = "0123456789abcdef";
static inline void byte2hex(const char* data, char** str) {
  **str = hex_table[(*data >> 4) & 0xf];
  ++*str;
  **str = hex_table[*data & 0xf];
  ++*str;
}
static inline void byte2char(const char* data, char** str) {
  **str = *data < ' ' ? '.' : *data > '~' ? '.' : *data;
  ++(*str);
}
static inline void word2hex(const char* data, char** hex) {
  byte2hex(&data[1], hex);
  byte2hex(&data[0], hex);
}
void dump_bin(const char* title, const char* data, int size) {
  char line_buff[256];
  char* line;
  int i, j, addr;
  const int width = 16;
  LOG_DEBUG(LOG_TAG, "%s, size:%d, dump started {", title, size);
  if (size <= 0) return;
  // write offset
  line = line_buff;
  *line++ = ' ';
  *line++ = ' ';
  *line++ = ' ';
  *line++ = ' ';
  *line++ = ' ';
  *line++ = ' ';
  for (j = 0; j < width; j++) {
    byte2hex((const char*)&j, &line);
    *line++ = ' ';
  }
  *line = 0;
  LOG_DEBUG(LOG_TAG, "%s", line_buff);

  for (i = 0; i < size / width; i++) {
    line = line_buff;
    // write address:
    addr = i * width;
    word2hex((const char*)&addr, &line);
    *line++ = ':';
    *line++ = ' ';
    // write hex of data
    for (j = 0; j < width; j++) {
      byte2hex(&data[j], &line);
      *line++ = ' ';
    }
    // write char of data
    for (j = 0; j < width; j++) byte2char(data++, &line);
    // wirte the end of line
    *line = 0;
    // output the line
    LOG_DEBUG(LOG_TAG, "%s", line_buff);
  }
  // last line of left over if any
  int leftover = size % width;
  if (leftover > 0) {
    line = line_buff;
    // write address:
    addr = i * width;
    word2hex((const char*)&addr, &line);
    *line++ = ':';
    *line++ = ' ';
    // write hex of data
    for (j = 0; j < leftover; j++) {
      byte2hex(&data[j], &line);
      *line++ = ' ';
    }
    // write hex padding
    for (; j < width; j++) {
      *line++ = ' ';
      *line++ = ' ';
      *line++ = ' ';
    }
    // write char of data
    for (j = 0; j < leftover; j++) byte2char(data++, &line);
    // write the end of line
    *line = 0;
    // output the line
    LOG_DEBUG(LOG_TAG, "%s", line_buff);
  }
  LOG_DEBUG(LOG_TAG, "%s, size:%d, dump ended }", title, size);
}