From f45986e88d2f5f3a1059be1d1124a8a0cbdc48ed Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Fri, 27 Jul 2018 18:33:14 +1000 Subject: [PATCH] Pedantically type-cast integer comparisons The latest versions of the GNU Compiler Collection complain about signed and unsigned integer comparisons when run with the "-Wextra" flag. Keep those compilers happy. --- src/exch.c | 2 +- src/intf.c | 2 +- src/move.c | 2 +- src/utils.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/exch.c b/src/exch.c index 2de2183..0d531ab 100644 --- a/src/exch.c +++ b/src/exch.c @@ -210,7 +210,7 @@ void exchange_stock (void) } for (i = 0, found = false; keycode_company[i] != L'\0'; i++) { - if (keycode_company[i] == key) { + if (keycode_company[i] == (wchar_t) key) { found = true; if (company[i].on_map) { selection = i; diff --git a/src/intf.c b/src/intf.c index 6d10f67..9898d21 100644 --- a/src/intf.c +++ b/src/intf.c @@ -1268,7 +1268,7 @@ void mkchstr_conv (chtype *restrict chbuf, int chbufsize, // Yes, we want to convert a wide NUL, too! n = xwcrtomb(convbuf, *wcbuf, &mbstate); - if (chbufsize > endsize + n) { + if (chbufsize > (int) endsize + (int) n) { for (p = convbuf; n > 0; n--, p++, chbuf++, chbufsize--) { if (*p == '\0' || *p == '\n') { /* This code assumes '\n' can never appear in a diff --git a/src/move.c b/src/move.c index 56db1f2..f0e5312 100644 --- a/src/move.c +++ b/src/move.c @@ -292,7 +292,7 @@ selection_t get_move (void) } for (i = 0, found = false; keycode_game_move[i] != L'\0'; i++) { - if (keycode_game_move[i] == key) { + if (keycode_game_move[i] == (wchar_t) key) { found = true; selection = i; diff --git a/src/utils.c b/src/utils.c index f821798..32a2ed6 100644 --- a/src/utils.c +++ b/src/utils.c @@ -747,7 +747,7 @@ char *unscramble (char *restrict dest, const char *restrict src, apply_xor(dest, midxor, xorlen - SCRAMBLE_CRC_LEN, key); // Convert the output to a C string - assert(size >= xorlen - SCRAMBLE_CRC_LEN + 1); + assert(size >= (size_t) xorlen - SCRAMBLE_CRC_LEN + 1); dest[xorlen - SCRAMBLE_CRC_LEN] = '\0'; free(xorbuf);