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 1/2] 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)) From 34fb7ba885ed9e9b91ad76004cdfc1d9a4709bbe Mon Sep 17 00:00:00 2001 From: Sean Qureshi Date: Thu, 12 Sep 2013 17:31:10 +0000 Subject: [PATCH 2/2] Manually merged changes by 1100110 --- src/chat.c | 2 +- src/prompt.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/chat.c b/src/chat.c index fd1b885..2efc314 100644 --- a/src/chat.c +++ b/src/chat.c @@ -324,7 +324,7 @@ static void execute(ToxWindow *self, ChatContext *ctx, StatusBar *statusbar, Tox else if (!strcmp(cmd, "/myid")) { char id[TOX_FRIEND_ADDRESS_SIZE * 2 + 1] = {'\0'}; - int i; + size_t i; uint8_t address[TOX_FRIEND_ADDRESS_SIZE]; tox_getaddress(m, address); diff --git a/src/prompt.c b/src/prompt.c index 420bfef..dd09d8f 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -87,7 +87,7 @@ void prompt_onFriendRequest(ToxWindow *prompt, uint8_t *key, uint8_t *data, uint int n = add_req(key); wprintw(prompt->window, "\nFriend request from:\n"); - int i; + size_t i; for (i = 0; i < KEY_SIZE_BYTES; ++i) { wprintw(prompt->window, "%02x", key[i] & 0xff); @@ -121,7 +121,7 @@ unsigned char *hex_string_to_bin(char hex_string[]) } char *pos = hex_string; - int i; + size_t i; for (i = 0; i < len; ++i, pos += 2) sscanf(pos, "%2hhx", &val[i]); @@ -168,7 +168,8 @@ void cmd_add(ToxWindow *self, Tox *m, int argc, char **argv) char xx[3]; uint32_t x; uint8_t *msg; - int i, num; + size_t i; + int num; char *id = argv[1]; @@ -477,7 +478,7 @@ static void execute(ToxWindow *self, Tox *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') @@ -595,7 +596,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m) { curs_set(1); int x, y; - int i; + size_t i; getyx(self->window, y, x); for (i = 0; i < (strlen(prompt_buf)); ++i) {