From 67a512759f0d8d4e16585b1f04c071f3ea08b8fa Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 24 Mar 2019 16:27:00 -0700 Subject: Add explicit casts to clear implicit conversion warnings xdpyinfo.c:173:17: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion] qsort(extlist, n, sizeof(char *), StrCmp); ~~~~~ ^ xdpyinfo.c:183:26: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion] qe_cookies = calloc(n, sizeof(xcb_query_extension_cookie_t)); ~~~~~~ ^ xdpyinfo.c:195:12: warning: implicit conversion loses integer precision: 'unsigned long' to 'uint16_t' (aka 'unsigned short') [-Wconversion] strlen(extlist[i]), ^~~~~~~~~~~~~~~~~~ xdpyinfo.c:1382:51: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32] int extlen = strlen(known_extensions[i].extname) + 1; ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ Signed-off-by: Alan Coopersmith --- xdpyinfo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xdpyinfo.c b/xdpyinfo.c index b9ddeb1..e57f26f 100644 --- a/xdpyinfo.c +++ b/xdpyinfo.c @@ -170,7 +170,7 @@ print_extension_info(Display *dpy) if (extlist) { int i; - qsort(extlist, n, sizeof(char *), StrCmp); + qsort(extlist, (size_t)n, sizeof(char *), StrCmp); if (!queryExtensions) { for (i = 0; i < n; i++) { @@ -180,7 +180,7 @@ print_extension_info(Display *dpy) xcb_connection_t *xcb_conn = XGetXCBConnection (dpy); xcb_query_extension_cookie_t *qe_cookies; - qe_cookies = calloc(n, sizeof(xcb_query_extension_cookie_t)); + qe_cookies = calloc((size_t)n, sizeof(xcb_query_extension_cookie_t)); if (!qe_cookies) { perror ("calloc failed to allocate memory for extensions"); return; @@ -192,7 +192,7 @@ print_extension_info(Display *dpy) */ for (i = 0; i < n; i++) { qe_cookies[i] = xcb_query_extension (xcb_conn, - strlen(extlist[i]), + (uint16_t)strlen(extlist[i]), extlist[i]); } @@ -1379,7 +1379,7 @@ print_known_extensions(FILE *f) int i, col; for (i = 0, col = 6; i < num_known_extensions; i++) { - int extlen = strlen(known_extensions[i].extname) + 1; + int extlen = (int) strlen(known_extensions[i].extname) + 1; if ((col + extlen) > 79) { -- cgit v1.2.3