From dabdffafa59f43314333be42aa519d7fff1b4498 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 23 Aug 2020 07:42:20 +0200 Subject: don't use empty struct initializers --- sixel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sixel.c') diff --git a/sixel.c b/sixel.c index 13596088..89d74061 100644 --- a/sixel.c +++ b/sixel.c @@ -231,7 +231,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six, row, col, height, width, rel_above, rel_below, rel_left, rel_right); - struct sixel imgs[4] = {}; + struct sixel imgs[4] = {0}; if (rel_above > 0) { imgs[0] = (struct sixel){ -- cgit v1.3 From e32c0d9bf698782353bbe9e4348617523af473bd Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 23 Aug 2020 07:50:27 +0200 Subject: Cast printf formatter %p arguments to void* --- fdm.c | 23 +++++++++++++++-------- input.c | 21 +++++++++++---------- shm.c | 8 ++++---- sixel.c | 2 +- 4 files changed, 31 insertions(+), 23 deletions(-) (limited to 'sixel.c') diff --git a/fdm.c b/fdm.c index 93ac86ff..980a464c 100644 --- a/fdm.c +++ b/fdm.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -263,7 +264,7 @@ fdm_hook_add(struct fdm *fdm, fdm_hook_t hook, void *data, #if defined(_DEBUG) tll_foreach(*hooks, it) { if (it->item.callback == hook) { - LOG_ERR("hook=%p already registered", hook); + LOG_ERR("hook=0x%" PRIxPTR " already registered", (uintptr_t)hook); return false; } } @@ -286,7 +287,7 @@ fdm_hook_del(struct fdm *fdm, fdm_hook_t hook, enum fdm_hook_priority priority) return true; } - LOG_WARN("hook=%p not registered", hook); + LOG_WARN("hook=0x%" PRIxPTR " not registered", (uintptr_t)hook); return false; } @@ -300,18 +301,24 @@ fdm_poll(struct fdm *fdm) } tll_foreach(fdm->hooks_high, it) { - LOG_DBG("executing high priority hook %p(fdm=%p, data=%p)", - it->item.callback, fdm, it->item.callback_data); + LOG_DBG( + "executing high priority hook 0x%" PRIxPTR" (fdm=%p, data=%p)", + (uintptr_t)it->item.callback, (void *)fdm, + (void *)it->item.callback_data); it->item.callback(fdm, it->item.callback_data); } tll_foreach(fdm->hooks_normal, it) { - LOG_DBG("executing normal priority hook %p(fdm=%p, data=%p)", - it->item.callback, fdm, it->item.callback_data); + LOG_DBG( + "executing normal priority hook 0x%" PRIxPTR " (fdm=%p, data=%p)", + (uintptr_t)it->item.callback, (void *)fdm, + (void *)it->item.callback_data); it->item.callback(fdm, it->item.callback_data); } tll_foreach(fdm->hooks_low, it) { - LOG_DBG("executing low priority hook %p(fdm=%p, data=%p)", - it->item.callback, fdm, it->item.callback_data); + LOG_DBG( + "executing low priority hook 0x%" PRIxPTR " (fdm=%p, data=%p)", + (uintptr_t)it->item.callback, (void *)fdm, + (void *)it->item.callback_data); it->item.callback(fdm, it->item.callback_data); } diff --git a/input.c b/input.c index 9d73af95..d6bc2e8e 100644 --- a/input.c +++ b/input.c @@ -422,7 +422,7 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size) { LOG_DBG("keyboard_keymap: keyboard=%p (format=%u, size=%u)", - wl_keyboard, format, size); + (void *)wl_keyboard, format, size); struct seat *seat = data; struct wayland *wayl = seat->wayl; @@ -505,7 +505,7 @@ keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, struct terminal *term = win->term; LOG_DBG("%s: keyboard_enter: keyboard=%p, serial=%u, surface=%p", - seat->name, wl_keyboard, serial, surface); + seat->name, (void *)wl_keyboard, serial, (void *)surface); if (seat->kbd.xkb == NULL) return; @@ -564,7 +564,7 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, struct seat *seat = data; LOG_DBG("keyboard_leave: keyboard=%p, serial=%u, surface=%p", - wl_keyboard, serial, surface); + (void *)wl_keyboard, serial, (void *)surface); if (seat->kbd.xkb == NULL) return; @@ -597,7 +597,7 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, */ LOG_WARN( "compositor sent keyboard_leave event without a keyboard_enter " - "event: surface=%p", surface); + "event: surface=%p", (void *)surface); } } @@ -795,7 +795,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial, LOG_DBG("keyboard_key: keyboard=%p, serial=%u, " "sym=%u, mod=0x%08x, consumed=0x%08x, significant=0x%08x, " "effective=0x%08x, repeats=%d", - wl_keyboard, serial, + (void *)wl_keyboard, serial, sym, mods, consumed, significant, effective_mods, should_repeat); /* @@ -1077,7 +1077,7 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, seat->pointer.hidden = false; LOG_DBG("pointer-enter: pointer=%p, serial=%u, surface = %p, new-moused = %p", - wl_pointer, serial, surface, term); + (void *)wl_pointer, serial, (void *)surface, (void *)term); /* Scale may have changed */ wayl_reload_xcursor_theme(seat, term->scale); @@ -1145,7 +1145,8 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, LOG_DBG( "%s: pointer-leave: pointer=%p, serial=%u, surface = %p, old-moused = %p", - seat->name, wl_pointer, serial, surface, old_moused); + seat->name, (void *)wl_pointer, serial, (void *)surface, + (void *)old_moused); seat->pointer.hidden = false; @@ -1170,7 +1171,7 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer, if (old_moused == NULL) { LOG_WARN( "compositor sent pointer_leave event without a pointer_enter " - "event: surface=%p", surface); + "event: surface=%p", (void *)surface); } else { if (surface != NULL) { /* Sway 1.4 sends this event with a NULL surface when we destroy the window */ @@ -1218,7 +1219,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer, struct terminal *term = seat->mouse_focus; struct wl_window *win = term->window; - LOG_DBG("pointer_motion: pointer=%p, x=%d, y=%d", wl_pointer, + LOG_DBG("pointer_motion: pointer=%p, x=%d, y=%d", (void *)wl_pointer, wl_fixed_to_int(surface_x), wl_fixed_to_int(surface_y)); assert(term != NULL); @@ -1353,7 +1354,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { LOG_DBG("BUTTON: pointer=%p, serial=%u, button=%x, state=%u", - wl_pointer, serial, button, state); + (void *)wl_pointer, serial, button, state); struct seat *seat = data; struct wayland *wayl = seat->wayl; diff --git a/shm.c b/shm.c index 587baa55..2b2c3435 100644 --- a/shm.c +++ b/shm.c @@ -116,7 +116,7 @@ static void buffer_release(void *data, struct wl_buffer *wl_buffer) { struct buffer *buffer = data; - LOG_DBG("release: cookie=%lx (buf=%p)", buffer->cookie, buffer); + LOG_DBG("release: cookie=%lx (buf=%p)", buffer->cookie, (void *)buffer); assert(buffer->wl_buf == wl_buffer); assert(buffer->busy); buffer->busy = false; @@ -208,7 +208,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, assert(!it->item.busy); LOG_DBG("cookie=%lx: purging buffer %p (width=%d, height=%d): %zu KB", - cookie, &it->item, it->item.width, it->item.height, + cookie, (void *)&it->item, it->item.width, it->item.height, it->item.size / 1024); buffer_destroy(&it->item); @@ -225,7 +225,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, if (!it->item.busy) { LOG_DBG("cookie=%lx: re-using buffer from cache (buf=%p)", - cookie, &it->item); + cookie, (void *)&it->item); it->item.busy = true; it->item.purge = false; assert(it->item.pix_instances == pix_instances); @@ -244,7 +244,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, if (it->item.width == width && it->item.height == height) continue; - LOG_DBG("cookie=%lx: marking buffer %p for purging", cookie, &it->item); + LOG_DBG("cookie=%lx: marking buffer %p for purging", cookie, (void *)&it->item); it->item.purge = true; } diff --git a/sixel.c b/sixel.c index 89d74061..27441d8c 100644 --- a/sixel.c +++ b/sixel.c @@ -227,7 +227,7 @@ sixel_overwrite(struct terminal *term, struct sixel *six, assert(rel_right >= 0); LOG_DBG("SPLIT: six (%p): %dx%d-%dx%d, %dx%d-%dx%d, rel: above=%d, below=%d, left=%d, right=%d", - six, six->pos.row, six->pos.col, six->rows, six->cols, + (void *)six, six->pos.row, six->pos.col, six->rows, six->cols, row, col, height, width, rel_above, rel_below, rel_left, rel_right); -- cgit v1.3 From aa3985a298d7770ef780324adea3ba0fe75b4e09 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 23 Aug 2020 09:37:51 +0200 Subject: Don't use "case X ... Y:", if possible/where it makes sense --- osc.c | 12 +++++++++--- sixel.c | 20 ++++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) (limited to 'sixel.c') diff --git a/osc.c b/osc.c index 20ceda8e..dcfaf524 100644 --- a/osc.c +++ b/osc.c @@ -339,9 +339,15 @@ static uint8_t nibble2hex(char c) { switch (c) { - case '0' ... '9': return c - '0'; - case 'a' ... 'f': return c - 'a' + 10; - case 'A' ... 'F': return c - 'A' + 10; + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + return c - '0'; + + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + return c - 'a' + 10; + + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + return c - 'A' + 10; } assert(false); diff --git a/sixel.c b/sixel.c index 27441d8c..c6fe1a10 100644 --- a/sixel.c +++ b/sixel.c @@ -668,7 +668,16 @@ decsixel(struct terminal *term, uint8_t c) term->sixel.pos.col = 0; break; - case '?'...'~': + case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': case 'K': case 'L': + case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case 'S': + case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': + case '[': case '\\': case ']': case '^': case '_': case '`': case 'a': + case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': + case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': + case 'w': case 'x': case 'y': case 'z': case '{': case '|': case '}': + case '~': sixel_add(term, term->sixel.palette[term->sixel.color_idx], c - 63); break; @@ -687,7 +696,8 @@ static void decgra(struct terminal *term, uint8_t c) { switch (c) { - case '0'...'9': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': term->sixel.param *= 10; term->sixel.param += c - '0'; break; @@ -732,7 +742,8 @@ static void decgri(struct terminal *term, uint8_t c) { switch (c) { - case '0'...'9': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': term->sixel.param *= 10; term->sixel.param += c - '0'; break; @@ -750,7 +761,8 @@ static void decgci(struct terminal *term, uint8_t c) { switch (c) { - case '0'...'9': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': term->sixel.param *= 10; term->sixel.param += c - '0'; break; -- cgit v1.3