diff options
author | NRK <nrk@disroot.org> | 2022-07-15 22:46:23 +0200 |
---|---|---|
committer | NRK <nrk@disroot.org> | 2022-07-15 22:46:23 +0200 |
commit | c131b1ed83da70fd739aff90ea3e8e829549ff43 (patch) | |
tree | f844587cc09b209c0edee2d3649589d62bc07215 /window.c | |
parent | 5cab2fb52520e6a24012351b936ebb9162494666 (diff) | |
download | nsxiv-c131b1ed83da70fd739aff90ea3e8e829549ff43.tar.zst |
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 <explosion-mental@noreply.codeberg.org>
Diffstat (limited to 'window.c')
-rw-r--r-- | window.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -259,7 +259,7 @@ void win_open(win_t *win) ButtonReleaseMask | ButtonPressMask | KeyPressMask | PointerMotionMask | StructureNotifyMask); - for (i = 0; i < ARRLEN(cursors); i++) { + for (i = 0; i < (int)ARRLEN(cursors); i++) { if (i != CURSOR_NONE) cursors[i].icon = XCreateFontCursor(e->dpy, cursors[i].name); } @@ -274,12 +274,12 @@ void win_open(win_t *win) n = icons[ARRLEN(icons)-1].size; icon_data = emalloc((n * n + 2) * sizeof(*icon_data)); - for (i = 0; i < ARRLEN(icons); i++) { + for (i = 0; i < (int)ARRLEN(icons); i++) { n = 0; icon_data[n++] = icons[i].size; icon_data[n++] = icons[i].size; - for (j = 0; j < icons[i].cnt; j++) { + for (j = 0; j < (int)icons[i].cnt; j++) { for (c = icons[i].data[j] >> 4; c >= 0; c--) icon_data[n++] = icon_colors[icons[i].data[j] & 0x0F]; } @@ -345,7 +345,7 @@ bool win_configure(win_t *win, XConfigureEvent *c) { bool changed; - changed = win->w != c->width || win->h + win->bar.h != c->height; + changed = win->w != (unsigned int)c->width || win->h + win->bar.h != (unsigned int)c->height; win->x = c->x; win->y = c->y; @@ -516,7 +516,7 @@ void win_set_title(win_t *win, const char *title, size_t len) { int i, targets[] = { ATOM_WM_NAME, ATOM_WM_ICON_NAME, ATOM__NET_WM_NAME, ATOM__NET_WM_ICON_NAME }; - for (i = 0; i < ARRLEN(targets); ++i) { + for (i = 0; i < (int)ARRLEN(targets); ++i) { XChangeProperty(win->env.dpy, win->xwin, atoms[targets[i]], atoms[ATOM_UTF8_STRING], 8, PropModeReplace, (unsigned char *)title, len); |