From c131b1ed83da70fd739aff90ea3e8e829549ff43 Mon Sep 17 00:00:00 2001 From: NRK Date: Fri, 15 Jul 2022 22:46:23 +0200 Subject: fix: -Wsign-compare warnings (#336) mixing signed and unsigned types in comparison can end up having unintended results. for example: if (-1 < 1U) printf("true\n"); else printf("false\n"); previously we silenced these warnings, instead just fix them properly via necessary casting, and in cases where the value cannot be negative (e.g width/height members) make them unsigned. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/336 Reviewed-by: explosion-mental --- commands.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'commands.c') diff --git a/commands.c b/commands.c index 8741a26..762fc05 100644 --- a/commands.c +++ b/commands.c @@ -36,7 +36,7 @@ bool cg_quit(arg_t status) unsigned int i; if (options->to_stdout && markcnt > 0) { - for (i = 0; i < filecnt; i++) { + for (i = 0; i < (unsigned int)filecnt; i++) { if (files[i].flags & FF_MARK) printf("%s%c", files[i].name, options->using_null ? '\0' : '\n'); } @@ -319,7 +319,7 @@ bool ci_drag(arg_t drag_mode) float px, py; XEvent e; - if ((int)(img.w * img.zoom) <= win.w && (int)(img.h * img.zoom) <= win.h) + if ((int)(img.w * img.zoom) <= (int)win.w && (int)(img.h * img.zoom) <= (int)win.h) return false; win_set_cursor(&win, drag_mode == DRAG_ABSOLUTE ? CURSOR_DRAG_ABSOLUTE : CURSOR_DRAG_RELATIVE); -- cgit v1.2.3-54-g00ecf