comparison of integers of different signs [-Wsign-compare]

This commit is contained in:
Philippe Teuwen 2019-04-13 23:38:34 +02:00
commit 97676d3210
17 changed files with 85 additions and 86 deletions

View file

@ -160,7 +160,7 @@ int FillBuffer(uint8_t *data, size_t maxDataLength, size_t *dataLength, ...) {
}
bool CheckStringIsHEXValue(const char *value) {
for (int i = 0; i < strlen(value); i++)
for (size_t i = 0; i < strlen(value); i++)
if (!isxdigit(value[i]))
return false;
@ -177,17 +177,17 @@ void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex
size_t i;
memset(tmp, 0x00, hex_max_len);
int maxLen = (hex_len > hex_max_len) ? hex_max_len : hex_len;
size_t maxLen = (hex_len > hex_max_len) ? hex_max_len : hex_len;
for (i = 0; i < maxLen; ++i, tmp += 2 + spaces_between) {
sprintf(tmp, (uppercase) ? "%02X" : "%02x", (unsigned int) hex_data[i]);
for (int j = 0; j < spaces_between; j++)
for (size_t j = 0; j < spaces_between; j++)
sprintf(tmp + 2 + j, " ");
}
i *= (2 + spaces_between);
int minStrLen = min_str_len > i ? min_str_len : 0;
size_t minStrLen = min_str_len > i ? min_str_len : 0;
if (minStrLen > hex_max_len)
minStrLen = hex_max_len;
for (; i < minStrLen; i++, tmp += 1)
@ -198,8 +198,7 @@ void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex
// printing and converting functions
void print_hex(const uint8_t *data, const size_t len) {
size_t i;
for (i = 0; i < len; i++)
for (size_t i = 0; i < len; i++)
printf("%02x ", data[i]);
printf("\n");
}
@ -207,7 +206,7 @@ void print_hex(const uint8_t *data, const size_t len) {
void print_hex_break(const uint8_t *data, const size_t len, uint8_t breaks) {
int rownum = 0;
printf("[%02d] | ", rownum);
for (int i = 0; i < len; ++i) {
for (size_t i = 0; i < len; ++i) {
printf("%02X ", data[i]);
@ -246,7 +245,7 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea
// make sure we don't go beyond our char array memory
size_t in_index = 0, out_index = 0;
int rowlen = (len > MAX_BIN_BREAK_LENGTH) ? MAX_BIN_BREAK_LENGTH : len;
size_t rowlen = (len > MAX_BIN_BREAK_LENGTH) ? MAX_BIN_BREAK_LENGTH : len;
if (breaks > 0 && len % breaks != 0)
rowlen = (len + (len / breaks) > MAX_BIN_BREAK_LENGTH) ? MAX_BIN_BREAK_LENGTH : len + (len / breaks);
@ -351,7 +350,7 @@ char *sprint_ascii_ex(const uint8_t *data, const size_t len, const size_t min_st
++i;
}
int m = min_str_len > i ? min_str_len : 0;
size_t m = min_str_len > i ? min_str_len : 0;
for (; i < m; ++i)
tmp[i] = ' ';
@ -399,7 +398,7 @@ void num_to_bytebits(uint64_t n, size_t len, uint8_t *dest) {
//least significant bit first
void num_to_bytebitsLSBF(uint64_t n, size_t len, uint8_t *dest) {
for (int i = 0 ; i < len ; ++i) {
for (size_t i = 0 ; i < len ; ++i) {
dest[i] = n & 1;
n >>= 1;
}
@ -876,7 +875,7 @@ int num_CPUs(void) {
}
void str_lower(char *s) {
for (int i = 0; i < strlen(s); i++)
for (size_t i = 0; i < strlen(s); i++)
s[i] = tolower(s[i]);
}
bool str_startswith(const char *s, const char *pre) {