From ddc8c53abf0790f3179a8daa7f6371e72b9b3389 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Mon, 30 Mar 2020 12:56:42 -0400 Subject: [PATCH] Fix unused variable warnings and change all (void)s to UNUSED macro --- src/audio_device.c | 3 ++- src/chat.c | 8 ++++++-- src/groupchat.c | 6 +++++- src/help.c | 3 ++- src/line_info.c | 11 ++++++++--- src/notify.c | 4 ++-- src/prompt.c | 7 +++++-- src/video_device.c | 2 +- src/xtra.c | 2 +- 9 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/audio_device.c b/src/audio_device.c index dbbfbaf..a24fc13 100644 --- a/src/audio_device.c +++ b/src/audio_device.c @@ -28,6 +28,7 @@ #include "line_info.h" #include "settings.h" +#include "misc_tools.h" #include #include @@ -456,7 +457,7 @@ void *thread_poll(void *arg) // TODO: maybe use thread for every input source /* * NOTE: We only need to poll input devices for data. */ - (void)arg; + UNUSED_VAR(arg); uint32_t i; int32_t sample = 0; diff --git a/src/chat.c b/src/chat.c index d403d09..64d8d1b 100644 --- a/src/chat.c +++ b/src/chat.c @@ -901,7 +901,7 @@ static void init_infobox(ToxWindow *self) return; } - (void) y2; + UNUSED_VAR(y2); memset(&ctx->infobox, 0, sizeof(struct infobox)); @@ -1011,6 +1011,8 @@ static void chat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) getyx(self->window, y, x); getmaxyx(self->window, y2, x2); + UNUSED_VAR(y); + if (y2 <= 0 || x2 <= 0) { return; } @@ -1239,7 +1241,9 @@ static void chat_onDraw(ToxWindow *self, Tox *m) int y, x; getyx(self->window, y, x); - (void) x; + + UNUSED_VAR(x); + int new_x = ctx->start ? x2 - 1 : MAX(0, wcswidth(ctx->line, ctx->pos)); wmove(self->window, y + 1, new_x); diff --git a/src/groupchat.c b/src/groupchat.c index bc21357..673b2cd 100644 --- a/src/groupchat.c +++ b/src/groupchat.c @@ -488,6 +488,8 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) getyx(self->window, y, x); getmaxyx(self->window, y2, x2); + UNUSED_VAR(y); + if (x2 <= 0 || y2 <= 0) { return; } @@ -666,7 +668,9 @@ static void groupchat_onDraw(ToxWindow *self, Tox *m) int y, x; getyx(self->window, y, x); - (void) x; + + UNUSED_VAR(x); + int new_x = ctx->start ? x2 - 1 : MAX(0, wcswidth(ctx->line, ctx->pos)); wmove(self->window, y + 1, new_x); diff --git a/src/help.c b/src/help.c index 52b26e2..de3cd78 100644 --- a/src/help.c +++ b/src/help.c @@ -138,7 +138,8 @@ static void help_draw_bottom_menu(WINDOW *win) { int y2, x2; getmaxyx(win, y2, x2); - (void) x2; + + UNUSED_VAR(x2); wmove(win, y2 - 2, 1); diff --git a/src/line_info.c b/src/line_info.c index d17a58b..b6a414e 100644 --- a/src/line_info.c +++ b/src/line_info.c @@ -270,7 +270,8 @@ static void line_info_check_queue(ToxWindow *self) int y, y2, x, x2; getmaxyx(self->window, y2, x2); getyx(self->chatwin->history, y, x); - (void) x; + + UNUSED_VAR(x); if (x2 <= SIDEBAR_WIDTH) { return; @@ -567,7 +568,9 @@ static void line_info_page_up(ToxWindow *self, struct history *hst) { int x2, y2; getmaxyx(self->window, y2, x2); - (void) x2; + + UNUSED_VAR(x2); + int jump_dist = y2 / 2; int i; @@ -580,7 +583,9 @@ static void line_info_page_down(ToxWindow *self, struct history *hst) { int x2, y2; getmaxyx(self->window, y2, x2); - (void) x2; + + UNUSED_VAR(x2); + int jump_dist = y2 / 2; int i; diff --git a/src/notify.c b/src/notify.c index 0750700..543829c 100644 --- a/src/notify.c +++ b/src/notify.c @@ -235,7 +235,7 @@ void graceful_clear(void) void *do_playing(void *_p) { - (void)_p; + UNUSED_VAR(_p); while (true) { control_lock(); @@ -334,7 +334,7 @@ int play_source(uint32_t source, uint32_t buffer, bool looping) #elif BOX_NOTIFY void *do_playing(void *_p) { - (void)_p; + UNUSED_VAR(_p); while (true) { control_lock(); diff --git a/src/prompt.c b/src/prompt.c index 594627e..0fd65c8 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -220,6 +220,8 @@ static void prompt_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr) getyx(self->window, y, x); getmaxyx(self->window, y2, x2); + UNUSED_VAR(y); + if (x2 <= 0 || y2 <= 0) { return; } @@ -416,7 +418,8 @@ static void prompt_onDraw(ToxWindow *self, Tox *m) int y, x; getyx(self->window, y, x); - (void) x; + + UNUSED_VAR(x); int new_x = ctx->start ? x2 - 1 : MAX(0, wcswidth(ctx->line, ctx->pos)); wmove(self->window, y + 1, new_x); @@ -508,7 +511,7 @@ void prompt_init_statusbar(ToxWindow *self, Tox *m, bool first_time_run) exit_toxic_err("failed in prompt_init_statusbar", FATALERR_CURSES); } - (void) y2; + UNUSED_VAR(y2); /* Init statusbar info */ StatusBar *statusbar = self->stb; diff --git a/src/video_device.c b/src/video_device.c index 4ccdce0..b07cefc 100644 --- a/src/video_device.c +++ b/src/video_device.c @@ -662,7 +662,7 @@ void *video_thread_poll(void *arg) // TODO: maybe use thread for every input so /* * NOTE: We only need to poll input devices for data. */ - (void)arg; + UNUSED_VAR(arg); uint32_t i; while (1) { diff --git a/src/xtra.c b/src/xtra.c index 6cb1f75..f81c671 100644 --- a/src/xtra.c +++ b/src/xtra.c @@ -232,7 +232,7 @@ void *event_loop(void *p) { /* Handle events like a real nigga */ - (void) p; /* DINDUNOTHIN */ + UNUSED_VAR(p); /* DINDUNOTHIN */ XEvent event; int pending;