From 90bec70e7f186f0e9dbf9e03e555ba50352caff2 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 24 Dec 2021 06:14:12 +0600 Subject: [PATCH] fix -Wshadow related warnings fixes all -Wshadow related warnings (on gcc). this would allow us to use `-Wshadow` in github workflow (https://github.com/nsxiv/nsxiv/pull/195). i've thought about adding `-Wshadow` to our Makefile as well, but decided against it to keep the Makefile CFLAGS barebore/minimal. --- commands.c | 6 +++--- image.c | 3 +-- main.c | 12 ++++++------ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/commands.c b/commands.c index 64f609d..423637b 100644 --- a/commands.c +++ b/commands.c @@ -328,7 +328,7 @@ bool ci_scroll_to_edge(arg_t dir) return img_pan_edge(&img, dir); } -bool ci_drag(arg_t mode) +bool ci_drag(arg_t drag_mode) { int x, y, ox, oy; float px, py; @@ -337,13 +337,13 @@ bool ci_drag(arg_t mode) if ((int)(img.w * img.zoom) <= win.w && (int)(img.h * img.zoom) <= win.h) return false; - win_set_cursor(&win, mode == DRAG_ABSOLUTE ? CURSOR_DRAG_ABSOLUTE : CURSOR_DRAG_RELATIVE); + win_set_cursor(&win, drag_mode == DRAG_ABSOLUTE ? CURSOR_DRAG_ABSOLUTE : CURSOR_DRAG_RELATIVE); win_cursor_pos(&win, &x, &y); ox = x; oy = y; while (true) { - if (mode == DRAG_ABSOLUTE) { + if (drag_mode == DRAG_ABSOLUTE) { px = MIN(MAX(0.0, x - win.w*0.1), win.w*0.8) / (win.w*0.8) * (win.w - img.w * img.zoom); py = MIN(MAX(0.0, y - win.h*0.1), win.h*0.8) / (win.h*0.8) diff --git a/image.c b/image.c index f8c6208..03c1f00 100644 --- a/image.c +++ b/image.c @@ -559,7 +559,6 @@ void img_render(img_t *img) int sx, sy, sw, sh; int dx, dy, dw, dh; Imlib_Image bg; - XColor c; win = img->win; img_fit(img); @@ -627,7 +626,7 @@ void img_render(img_t *img) } imlib_image_put_back_data(data); } else { - c = win->win_bg; + XColor c = win->win_bg; imlib_context_set_color(c.red >> 8, c.green >> 8, c.blue >> 8, 0xFF); imlib_image_fill_rectangle(0, 0, dw, dh); } diff --git a/main.c b/main.c index 34c0254..f8c727f 100644 --- a/main.c +++ b/main.c @@ -605,19 +605,19 @@ end: return true; } -static bool process_bindings(const keymap_t *keys, unsigned int len, KeySym ksym_or_button, +static bool process_bindings(const keymap_t *bindings, unsigned int len, KeySym ksym_or_button, unsigned int state, unsigned int implicit_mod) { unsigned int i; bool dirty = false; for (i = 0; i < len; i++) { - if (keys[i].ksym_or_button == ksym_or_button && - MODMASK(keys[i].mask | implicit_mod) == MODMASK(state) && - keys[i].cmd.func && - (keys[i].cmd.mode == MODE_ALL || keys[i].cmd.mode == mode)) + if (bindings[i].ksym_or_button == ksym_or_button && + MODMASK(bindings[i].mask | implicit_mod) == MODMASK(state) && + bindings[i].cmd.func && + (bindings[i].cmd.mode == MODE_ALL || bindings[i].cmd.mode == mode)) { - if (keys[i].cmd.func(keys[i].arg)) + if (bindings[i].cmd.func(bindings[i].arg)) dirty = true; } }