From 91a2ef1d84cdb94923251a18a80cd8946e70c790 Mon Sep 17 00:00:00 2001 From: Jude <0b1100110@gmail.com> Date: Fri, 23 Aug 2013 11:41:54 -0500 Subject: [PATCH] warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare] --- src/chat.c | 3 +-- src/prompt.c | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/chat.c b/src/chat.c index 30b8d95..d3d46c2 100644 --- a/src/chat.c +++ b/src/chat.c @@ -359,11 +359,10 @@ void execute(ToxWindow *self, ChatContext *ctx, Messenger *m, char *cmd) else if (!strcmp(cmd, "/myid")) { char id[FRIEND_ADDRESS_SIZE * 2 + 1] = {0}; - int i; uint8_t address[FRIEND_ADDRESS_SIZE]; getaddress(m, address); - for (i = 0; i < FRIEND_ADDRESS_SIZE; i++) { + for (size_t i = 0; i < FRIEND_ADDRESS_SIZE; i++) { char xx[3]; snprintf(xx, sizeof(xx), "%02X", address[i] & 0xff); strcat(id, xx); diff --git a/src/prompt.c b/src/prompt.c index 887c486..0bae4d1 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -75,9 +75,8 @@ unsigned char *hex_string_to_bin(char hex_string[]) size_t len = strlen(hex_string); unsigned char *val = malloc(len); char *pos = hex_string; - int i; - for (i = 0; i < len; ++i, pos += 2) + for (size_t i = 0; i < len; ++i, pos += 2) sscanf(pos, "%2hhx", &val[i]); return val; @@ -123,7 +122,7 @@ void cmd_add(ToxWindow *self, Messenger *m, char **args) return; } - int i; + size_t i; for (i = 0; i < FRIEND_ADDRESS_SIZE; ++i) { xx[0] = id[2 * i]; @@ -332,7 +331,7 @@ static void execute(ToxWindow *self, Messenger *m, char *u_cmd) { int newlines = 0; char cmd[MAX_STR_SIZE] = {0}; - int i; + size_t i; for (i = 0; i < strlen(prompt_buf); ++i) { if (u_cmd[i] == '\n') @@ -478,7 +477,7 @@ static void prompt_onDraw(ToxWindow *self, Messenger *m) int x, y; getyx(self->window, y, x); (void) x; - int i; + size_t i; for (i = 0; i < (strlen(prompt_buf)); ++i) { if ((prompt_buf[i] == '\n') && (y != 0))