From: Erik de Castro Lopo Date: Sat, 11 Jun 2016 03:16:03 +0000 (+1000) Subject: Fix more compiler warnings X-Git-Url: https://scope-eye.net/git/?a=commitdiff_plain;h=17f374f85c0900728289274337200bdd14aca144;p=liskon_frotz.git Fix more compiler warnings --- diff --git a/src/common/unused.h b/src/common/unused.h new file mode 100644 index 0000000..7498161 --- /dev/null +++ b/src/common/unused.h @@ -0,0 +1,23 @@ +/* +** Insired by code from Martin Pool. +*/ + +#ifndef COMMON_UNUSED_H +#define COMMON_UNUSED_H + +#ifdef UNUSED +#elif defined (__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__ ((unused)) +#elif defined (__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +#ifdef __GNUC__ +# define WARN_UNUSED __attribute__ ((warn_unused_result)) +#else +# define WARN_UNUSED +#endif + +#endif diff --git a/src/curses/ux_text.c b/src/curses/ux_text.c index 2aa8cfa..57d3b75 100644 --- a/src/curses/ux_text.c +++ b/src/curses/ux_text.c @@ -206,7 +206,7 @@ void os_set_font (int new_font) */ void os_display_char (zchar c) { - if (c >= ZC_LATIN1_MIN && c <= ZC_LATIN1_MAX) { + if (c >= ZC_LATIN1_MIN) { if (u_setup.plain_ascii) { char *ptr = latin1_to_ascii + 3 * (c - ZC_LATIN1_MIN); @@ -274,7 +274,7 @@ void os_display_string (const zchar *s) */ int os_char_width (zchar c) { - if (c >= ZC_LATIN1_MIN && c <= ZC_LATIN1_MAX && u_setup.plain_ascii) { + if (c >= ZC_LATIN1_MIN && u_setup.plain_ascii) { int width = 0; const char *ptr = latin1_to_ascii + 3 * (c - ZC_LATIN1_MIN); diff --git a/src/dumb/dumb_init.c b/src/dumb/dumb_init.c index 58c262f..961613a 100644 --- a/src/dumb/dumb_init.c +++ b/src/dumb/dumb_init.c @@ -6,6 +6,7 @@ */ #include "dumb_frotz.h" +#include "../common/unused.h" f_setup_t f_setup; @@ -158,7 +159,7 @@ int os_random_seed (void) else return user_random_seed; } -void os_restart_game (int stage) {} +void os_restart_game (int UNUSED (stage)) {} void os_fatal (const char *s, ...) { diff --git a/src/dumb/dumb_input.c b/src/dumb/dumb_input.c index 7238ba3..701ec71 100644 --- a/src/dumb/dumb_input.c +++ b/src/dumb/dumb_input.c @@ -5,6 +5,8 @@ */ #include "dumb_frotz.h" +#include "../common/unused.h" + f_setup_t f_setup; static char runtime_usage[] = @@ -248,7 +250,7 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor, if (type != INPUT_LINE_CONTINUED) fprintf(stderr, "DUMB-FROTZ: No input to discard\n"); else { - dumb_discard_old_input(strlen(continued_line_chars)); + dumb_discard_old_input(strlen((char*) continued_line_chars)); continued_line_chars[0] = '\0'; type = INPUT_LINE; } @@ -263,7 +265,7 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor, for (i = 0; (i < h_screen_rows - 2) && *next_page; i++) next_page = strchr(next_page, '\n') + 1; /* next_page - current_page is width */ - printf("%.*s", next_page - current_page, current_page); + printf("%.*s", (int) (next_page - current_page), current_page); current_page = next_page; if (!*current_page) break; @@ -329,7 +331,7 @@ zchar os_read_key (int timeout, bool show_cursor) return c; } -zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued) +zchar os_read_line (int UNUSED (max), zchar *buf, int timeout, int UNUSED(width), int continued) { char *p; int terminator; @@ -370,7 +372,7 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued) dumb_display_user_input(read_line_buffer); /* copy to the buffer and save the rest for next time. */ - strcat(buf, read_line_buffer); + strcat((char*) buf, read_line_buffer); p = read_line_buffer + strlen(read_line_buffer) + 1; memmove(read_line_buffer, p, strlen(p) + 1); diff --git a/src/dumb/dumb_output.c b/src/dumb/dumb_output.c index 310cc08..31ec727 100644 --- a/src/dumb/dumb_output.c +++ b/src/dumb/dumb_output.c @@ -6,6 +6,7 @@ */ #include "dumb_frotz.h" +#include "../common/unused.h" f_setup_t f_setup; @@ -74,7 +75,7 @@ static char *dumb_changes_row(int r) int os_char_width (zchar z) { - if (plain_ascii && z >= ZC_LATIN1_MIN && z <= ZC_LATIN1_MAX) { + if (plain_ascii && z >= ZC_LATIN1_MIN) { char *p = latin1_to_ascii + 4 * (z - ZC_LATIN1_MIN); return strchr(p, ' ') - p; } @@ -164,7 +165,7 @@ void dumb_discard_old_input(int num_chars) void os_display_char (zchar c) { - if (c >= ZC_LATIN1_MIN && c <= ZC_LATIN1_MAX) { + if (c >= ZC_LATIN1_MIN) { if (plain_ascii) { char *ptr = latin1_to_ascii + 4 * (c - ZC_LATIN1_MIN); do @@ -199,7 +200,7 @@ void os_display_string (const zchar *s) } } -void os_erase_area (int top, int left, int bottom, int right, int win) +void os_erase_area (int top, int left, int bottom, int right, int UNUSED (win)) { int row, col; top--; left--; bottom--; right--; @@ -238,8 +239,8 @@ int os_font_data(int font, int *height, int *width) return 0; } -void os_set_colour (int x, int y) {} -void os_set_font (int x) {} +void os_set_colour (int UNUSED (x), int UNUSED (y)) {} +void os_set_font (int UNUSED (x)) {} /* Print a cell to stdout. */ static void show_cell(cell cel) @@ -432,10 +433,10 @@ void os_beep (int volume) /* To make the common code happy */ void os_init_sound(void) {} -void os_prepare_sample (int a) {} -void os_finish_with_sample (int a) {} -void os_start_sample (int a, int b, int c, zword d) {} -void os_stop_sample (int a) {} +void os_prepare_sample (int UNUSED (a)) {} +void os_finish_with_sample (int UNUSED (a)) {} +void os_start_sample (int UNUSED (a), int UNUSED (b), int UNUSED (c), zword UNUSED (d)) {} +void os_stop_sample (int UNUSED (a)) {} /* if val is '0' or '1', set *var accordingly, else toggle it. */