From 1a50edf62c9511a2bee8b7cc3b72e5185f7b593f Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 9 Jun 2019 10:21:39 -0700 Subject: Clear -Wsign-compare warnings from gcc 7.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dsimple.c: In function ‘recursive_Window_With_Name’: dsimple.c:298:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if ((namelen == prop_name_len) && ^~ dsimple.c:336:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if ((namelen == prop_name_len) && ^~ dsimple.c:371:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (i = 0; i < nchildren; i++) { ^ dsimple.c:380:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (i = 0; i < nchildren; i++) { ^ dsimple.c:390:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (/* keep previous i */; i < nchildren; i++) { ^ dsimple.c: In function ‘Get_Atom’: dsimple.c:616:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (a->atom == -1) /* internal error */ ^~ xwininfo.c: In function ‘wm_size_hints_reply’: xwininfo.c:730:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (length > sizeof(wm_size_hints_t)) ^ xwininfo.c: In function ‘Display_Event_Mask’: xwininfo.c:1229:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (bit=0, bit_mask=1; bit < sizeof(long)*8; bit++, bit_mask <<= 1) ^ xwininfo.c: In function ‘wm_hints_reply’: xwininfo.c:1633:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (length > sizeof(wm_hints_t)) ^ xwininfo.c: In function ‘is_valid_utf8’: xwininfo.c:1843:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for (i = 0; i < len; i++) { ^ Signed-off-by: Alan Coopersmith --- dsimple.c | 12 ++++++------ xwininfo.c | 13 +++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dsimple.c b/dsimple.c index ca746e9..fc050c9 100644 --- a/dsimple.c +++ b/dsimple.c @@ -279,7 +279,7 @@ recursive_Window_With_Name ( { xcb_window_t *children; unsigned int nchildren; - int i; + unsigned int i; xcb_window_t w = 0; xcb_generic_error_t *err; xcb_query_tree_reply_t *tree; @@ -295,7 +295,7 @@ recursive_Window_With_Name ( int prop_name_len = xcb_get_property_value_length (prop); /* can't use strcmp, since prop.name is not null terminated */ - if ((namelen == prop_name_len) && + if ((namelen == (size_t) prop_name_len) && memcmp (prop_name, name, namelen) == 0) { w = window; } @@ -317,7 +317,7 @@ recursive_Window_With_Name ( if (xcb_icccm_get_wm_name_reply (dpy, cookies->get_wm_name, &nameprop, &err)) { /* can't use strcmp, since nameprop.name is not null terminated */ - if ((namelen == nameprop.name_len) && + if ((namelen == (size_t) nameprop.name_len) && memcmp (nameprop.name, name, namelen) == 0) { w = window; } @@ -333,7 +333,7 @@ recursive_Window_With_Name ( int prop_name_len = xcb_get_property_value_length (prop); /* can't use strcmp, since prop.name is not null terminated */ - if ((namelen == prop_name_len) && + if ((namelen == (size_t) prop_name_len) && memcmp (prop_name, name, namelen) == 0) { w = window; } @@ -610,10 +610,10 @@ xcb_atom_t Get_Atom (xcb_connection_t * dpy, const char *name) a->atom = reply->atom; free (reply); } else { - a->atom = -1; + a->atom = (xcb_atom_t) -1; } } - if (a->atom == -1) /* internal error */ + if (a->atom == (xcb_atom_t) -1) /* internal error */ return XCB_ATOM_NONE; return a->atom; diff --git a/xwininfo.c b/xwininfo.c index 7d2f77e..73cc344 100644 --- a/xwininfo.c +++ b/xwininfo.c @@ -716,7 +716,7 @@ wm_size_hints_reply (xcb_connection_t *wshr_dpy, xcb_get_property_cookie_t cooki wm_size_hints_t *hints_return, xcb_generic_error_t **wshr_err) { xcb_get_property_reply_t *prop = xcb_get_property_reply (wshr_dpy, cookie, wshr_err); - int length; + size_t length; if (!prop || (prop->type != XCB_ATOM_WM_SIZE_HINTS) || (prop->format != 32)) { @@ -726,7 +726,7 @@ wm_size_hints_reply (xcb_connection_t *wshr_dpy, xcb_get_property_cookie_t cooki memset (hints_return, 0, sizeof(wm_size_hints_t)); - length = xcb_get_property_value_length(prop); + length = (size_t) xcb_get_property_value_length(prop); if (length > sizeof(wm_size_hints_t)) length = sizeof(wm_size_hints_t); memcpy (hints_return, xcb_get_property_value (prop), length); @@ -1224,7 +1224,7 @@ static const binding _event_mask_names[] = { static void Display_Event_Mask (long mask) { - long bit, bit_mask; + unsigned long bit, bit_mask; for (bit=0, bit_mask=1; bit < sizeof(long)*8; bit++, bit_mask <<= 1) if (mask & bit_mask) @@ -1620,7 +1620,7 @@ wm_hints_reply (xcb_connection_t *whr_dpy, xcb_get_property_cookie_t cookie, wm_hints_t *hints_return, xcb_generic_error_t **whr_err) { xcb_get_property_reply_t *prop = xcb_get_property_reply (whr_dpy, cookie, whr_err); - int length; + size_t length; if (!prop || (prop->type != XCB_ATOM_WM_HINTS) || (prop->format != 32)) { free (prop); @@ -1629,7 +1629,7 @@ wm_hints_reply (xcb_connection_t *whr_dpy, xcb_get_property_cookie_t cookie, memset (hints_return, 0, sizeof(wm_hints_t)); - length = xcb_get_property_value_length(prop); + length = (size_t) xcb_get_property_value_length(prop); if (length > sizeof(wm_hints_t)) length = sizeof(wm_hints_t); memcpy (hints_return, xcb_get_property_value (prop), length); @@ -1836,7 +1836,8 @@ static int is_valid_utf8 (const char *string, size_t len) { unsigned long codepoint; - int rem, i; + int rem; + size_t i; unsigned char c; rem = 0; -- cgit v1.2.3