Merge branch 'pedantic' into master

This commit is contained in:
Daniel Eklöf 2020-08-25 18:54:21 +02:00
commit 777a2eac51
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
16 changed files with 145 additions and 97 deletions

View file

@ -4,7 +4,7 @@ pkgrel=1
arch=('x86_64' 'aarch64')
url=https://codeberg.org/dnkl/foot
license=(mit)
makedepends=('meson' 'ninja' 'scdoc' 'python' 'ncurses' 'wayland-protocols' 'tllist>=1.0.1')
makedepends=('meson' 'ninja' 'scdoc' 'python' 'ncurses' 'wayland-protocols' 'tllist>=1.0.4')
depends=('libxkbcommon' 'wayland' 'pixman' 'fontconfig' 'fcft>=2.2.2')
source=()

View file

@ -105,10 +105,10 @@ static const char *const search_binding_action_map[] = {
static_assert(ALEN(search_binding_action_map) == BIND_ACTION_SEARCH_COUNT,
"search binding action map size mismatch");
#define LOG_AND_NOTIFY_ERR(fmt, ...) \
#define LOG_AND_NOTIFY_ERR(...) \
do { \
LOG_ERR(fmt, ## __VA_ARGS__); \
char *text = xasprintf(fmt, ## __VA_ARGS__); \
LOG_ERR(__VA_ARGS__); \
char *text = xasprintf(__VA_ARGS__); \
struct user_notification notif = { \
.kind = USER_NOTIFICATION_ERROR, \
.text = text, \
@ -116,10 +116,10 @@ static_assert(ALEN(search_binding_action_map) == BIND_ACTION_SEARCH_COUNT,
tll_push_back(conf->notifications, notif); \
} while (0)
#define LOG_AND_NOTIFY_WARN(fmt, ...) \
#define LOG_AND_NOTIFY_WARN(...) \
do { \
LOG_WARN(fmt, ## __VA_ARGS__); \
char *text = xasprintf(fmt, ## __VA_ARGS__); \
LOG_WARN(__VA_ARGS__); \
char *text = xasprintf(__VA_ARGS__); \
struct user_notification notif = { \
.kind = USER_NOTIFICATION_WARNING, \
.text = text, \
@ -127,14 +127,14 @@ static_assert(ALEN(search_binding_action_map) == BIND_ACTION_SEARCH_COUNT,
tll_push_back(conf->notifications, notif); \
} while (0)
#define LOG_AND_NOTIFY_ERRNO(fmt, ...) \
#define LOG_AND_NOTIFY_ERRNO(...) \
do { \
int _errno = errno; \
LOG_ERRNO(fmt, ## __VA_ARGS__); \
int len = snprintf(NULL, 0, fmt, ## __VA_ARGS__); \
LOG_ERRNO(__VA_ARGS__); \
int len = snprintf(NULL, 0, __VA_ARGS__); \
int errno_len = snprintf(NULL, 0, ": %s", strerror(_errno)); \
char *text = xmalloc(len + errno_len + 1); \
snprintf(text, len + errno_len + 1, fmt, ## __VA_ARGS__); \
snprintf(text, len + errno_len + 1, __VA_ARGS__); \
snprintf(&text[len], errno_len + 1, ": %s", strerror(_errno)); \
struct user_notification notif = { \
.kind = USER_NOTIFICATION_ERROR, \
@ -689,7 +689,7 @@ parse_modifiers(struct config *conf, const char *text, size_t len,
{
bool ret = false;
*modifiers = (struct config_key_modifiers){};
*modifiers = (struct config_key_modifiers){0};
char *copy = xstrndup(text, len);
for (char *tok_ctx = NULL, *key = strtok_r(copy, "+", &tok_ctx);
@ -730,7 +730,7 @@ parse_key_combos(struct config *conf, const char *combos, key_combo_list_t *key_
combo != NULL;
combo = strtok_r(NULL, " ", &tok_ctx))
{
struct config_key_modifiers modifiers = {};
struct config_key_modifiers modifiers = {0};
const char *key = strrchr(combo, '+');
if (key == NULL) {
@ -1018,7 +1018,7 @@ parse_mouse_combos(struct config *conf, const char *combos, key_combo_list_t *ke
combo != NULL;
combo = strtok_r(NULL, " ", &tok_ctx))
{
struct config_key_modifiers modifiers = {};
struct config_key_modifiers modifiers = {0};
char *key = strrchr(combo, '+');
if (key == NULL) {
@ -1494,7 +1494,7 @@ add_default_search_bindings(struct config *conf)
((struct config_key_binding_search){action, mods, sym})); \
} while (0)
const struct config_key_modifiers none = {};
const struct config_key_modifiers none = {0};
const struct config_key_modifiers alt = {.alt = true};
const struct config_key_modifiers ctrl = {.ctrl = true};
const struct config_key_modifiers ctrl_shift = {.ctrl = true, .shift = true};
@ -1538,7 +1538,7 @@ add_default_mouse_bindings(struct config *conf)
((struct config_mouse_binding){action, mods, btn, count})); \
} while (0)
const struct config_key_modifiers none = {};
const struct config_key_modifiers none = {0};
const struct config_key_modifiers ctrl = {.ctrl = true};
add_binding(BIND_ACTION_PRIMARY_PASTE, none, BTN_MIDDLE, 1);

23
fdm.c
View file

@ -2,6 +2,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
@ -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);
}

29
input.c
View file

@ -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;
@ -549,7 +549,7 @@ stop_repeater(struct seat *seat, uint32_t key)
if (key != -1 && key != seat->kbd.repeat.key)
return true;
if (timerfd_settime(seat->kbd.repeat.fd, 0, &(struct itimerspec){}, NULL) < 0) {
if (timerfd_settime(seat->kbd.repeat.fd, 0, &(struct itimerspec){{0}}, NULL) < 0) {
LOG_ERRNO("%s: failed to disarm keyboard repeat timer", seat->name);
return false;
}
@ -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);
/*
@ -843,7 +843,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
* Compose, and maybe emit "normal" character
*/
uint8_t buf[64] = {};
uint8_t buf[64] = {0};
int count = 0;
if (compose_status == XKB_COMPOSE_COMPOSED) {
@ -923,7 +923,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
const wchar_t wc = 0x80 | buf[0];
char utf8[8];
mbstate_t ps = {};
mbstate_t ps = {0};
size_t chars = wcrtomb(utf8, wc, &ps);
if (chars != (size_t)-1)
@ -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;
@ -1544,7 +1545,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
continue;
}
const struct config_key_modifiers no_mods = {};
const struct config_key_modifiers no_mods = {0};
if (memcmp(&binding->modifiers, &no_mods, sizeof(no_mods)) != 0) {
/* Binding has modifiers */
continue;

26
log.h
View file

@ -23,21 +23,21 @@ void log_errno_provided(
const char *file, int lineno, int _errno,
const char *fmt, ...) PRINTF(6);
#define LOG_ERR(fmt, ...) \
log_msg(LOG_CLASS_ERROR, LOG_MODULE, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
#define LOG_ERRNO(fmt, ...) \
log_errno(LOG_CLASS_ERROR, LOG_MODULE, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
#define LOG_ERRNO_P(fmt, _errno, ...) \
#define LOG_ERR(...) \
log_msg(LOG_CLASS_ERROR, LOG_MODULE, __FILE__, __LINE__, __VA_ARGS__)
#define LOG_ERRNO(...) \
log_errno(LOG_CLASS_ERROR, LOG_MODULE, __FILE__, __LINE__, __VA_ARGS__)
#define LOG_ERRNO_P(_errno, ...) \
log_errno_provided(LOG_CLASS_ERROR, LOG_MODULE, __FILE__, __LINE__, \
_errno, fmt, ## __VA_ARGS__)
#define LOG_WARN(fmt, ...) \
log_msg(LOG_CLASS_WARNING, LOG_MODULE, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
#define LOG_INFO(fmt, ...) \
log_msg(LOG_CLASS_INFO, LOG_MODULE, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
_errno, __VA_ARGS__)
#define LOG_WARN(...) \
log_msg(LOG_CLASS_WARNING, LOG_MODULE, __FILE__, __LINE__, __VA_ARGS__)
#define LOG_INFO(...) \
log_msg(LOG_CLASS_INFO, LOG_MODULE, __FILE__, __LINE__, __VA_ARGS__)
#if defined(LOG_ENABLE_DBG) && LOG_ENABLE_DBG
#define LOG_DBG(fmt, ...) \
log_msg(LOG_CLASS_DEBUG, LOG_MODULE, __FILE__, __LINE__, fmt, ## __VA_ARGS__)
#define LOG_DBG(...) \
log_msg(LOG_CLASS_DEBUG, LOG_MODULE, __FILE__, __LINE__, __VA_ARGS__)
#else
#define LOG_DBG(fmt, ...)
#define LOG_DBG(...)
#endif

View file

@ -18,7 +18,8 @@ add_project_arguments(
? ['-D_DEBUG']
: [cc.get_supported_arguments('-fno-asynchronous-unwind-tables')]) +
cc.get_supported_arguments(
['-fstrict-aliasing',
['-pedantic',
'-fstrict-aliasing',
'-Wstrict-aliasing']),
language: 'c',
)
@ -60,7 +61,7 @@ wayland_cursor = dependency('wayland-cursor')
xkb = dependency('xkbcommon')
fontconfig = dependency('fontconfig')
tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')
tllist = dependency('tllist', version: '>=1.0.4', fallback: 'tllist')
fcft = dependency('fcft', version: ['>=2.2.2', '<3.0.0'], fallback: 'fcft')
wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir')

12
osc.c
View file

@ -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);

View file

@ -36,7 +36,7 @@ static struct {
size_t zero; /* commits presented in less than one frame interval */
size_t one; /* commits presented in one frame interval */
size_t two; /* commits presented in two or more frame intervals */
} presentation_statistics = {};
} presentation_statistics = {0};
static void fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data);
@ -952,11 +952,11 @@ get_csd_data(const struct terminal *term, enum csd_surface surf_idx)
case CSD_SURF_COUNT:
assert(false);
return (struct csd_data){};
return (struct csd_data){0};
}
assert(false);
return (struct csd_data){};
return (struct csd_data){0};
}
static void

View file

@ -648,7 +648,7 @@ search_input(struct seat *seat, struct terminal *term, uint32_t key,
}
}
uint8_t buf[64] = {};
uint8_t buf[64] = {0};
int count = 0;
if (compose_status == XKB_COMPOSE_COMPOSED) {
@ -666,7 +666,7 @@ search_input(struct seat *seat, struct terminal *term, uint32_t key,
return;
const char *src = (const char *)buf;
mbstate_t ps = {};
mbstate_t ps = {0};
size_t wchars = mbsnrtowcs(NULL, &src, count, 0, &ps);
if (wchars == -1) {

View file

@ -184,10 +184,12 @@ foreach_selected(
{
switch (term->selection.kind) {
case SELECTION_NORMAL:
return foreach_selected_normal(term, start, end, cb, data);
foreach_selected_normal(term, start, end, cb, data);
return;
case SELECTION_BLOCK:
return foreach_selected_block(term, start, end, cb, data);
foreach_selected_block(term, start, end, cb, data);
return;
case SELECTION_NONE:
assert(false);
@ -325,7 +327,7 @@ selection_modify(struct terminal *term, struct coord start, struct coord end)
assert(start.row != -1 && start.col != -1);
assert(end.row != -1 && end.col != -1);
struct mark_context ctx = {};
struct mark_context ctx = {0};
/* Premark all cells that *will* be selected */
foreach_selected(term, start, end, &premark_selected, &ctx);
@ -452,7 +454,7 @@ selection_dirty_cells(struct terminal *term)
foreach_selected(
term, term->selection.start, term->selection.end, &mark_selected,
&(struct mark_context){});
&(struct mark_context){0});
}
static void
@ -647,7 +649,7 @@ selection_cancel(struct terminal *term)
if (term->selection.start.row >= 0 && term->selection.end.row >= 0) {
foreach_selected(
term, term->selection.start, term->selection.end,
&unmark_selected, &(struct mark_context){});
&unmark_selected, &(struct mark_context){0});
render_refresh(term);
}
@ -1059,7 +1061,8 @@ begin_receive_clipboard(struct terminal *term, int read_fd,
{
LOG_ERRNO("failed to set O_NONBLOCK");
close(read_fd);
return done(user);
done(user);
return;
}
struct clipboard_receive *ctx = xmalloc(sizeof(*ctx));
@ -1082,14 +1085,17 @@ text_from_clipboard(struct seat *seat, struct terminal *term,
void (*done)(void *user), void *user)
{
struct wl_clipboard *clipboard = &seat->clipboard;
if (clipboard->data_offer == NULL)
return done(user);
if (clipboard->data_offer == NULL) {
done(user);
return;
}
/* Prepare a pipe the other client can write its selection to us */
int fds[2];
if (pipe2(fds, O_CLOEXEC) == -1) {
LOG_ERRNO("failed to create pipe");
return done(user);
done(user);
return;
}
int read_fd = fds[0];
@ -1197,18 +1203,23 @@ text_from_primary(
void (*cb)(const char *data, size_t size, void *user),
void (*done)(void *user), void *user)
{
if (term->wl->primary_selection_device_manager == NULL)
return done(user);
if (term->wl->primary_selection_device_manager == NULL) {
done(user);
return;
}
struct wl_primary *primary = &seat->primary;
if (primary->data_offer == NULL)
return done(user);
if (primary->data_offer == NULL){
done(user);
return;
}
/* Prepare a pipe the other client can write its selection to us */
int fds[2];
if (pipe2(fds, O_CLOEXEC) == -1) {
LOG_ERRNO("failed to create pipe");
return done(user);
done(user);
return;
}
int read_fd = fds[0];

8
shm.c
View file

@ -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;
}

24
sixel.c
View file

@ -227,11 +227,11 @@ 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);
struct sixel imgs[4] = {};
struct sixel imgs[4] = {0};
if (rel_above > 0) {
imgs[0] = (struct sixel){
@ -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;

View file

@ -281,7 +281,7 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
sigprocmask(SIG_SETMASK, &mask, NULL) < 0)
{
const int _errno = errno;
LOG_ERRNO_P("failed to restore signals", errno);
LOG_ERRNO_P(errno, "failed to restore signals");
(void)!write(fork_pipe[1], &_errno, sizeof(_errno));
_exit(_errno);
}
@ -332,7 +332,8 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
return -1;
} else if (ret == sizeof(_errno)) {
LOG_ERRNO_P(
"%s: failed to execute", _errno, argc == 0 ? conf_shell : argv[0]);
_errno, "%s: failed to execute",
argc == 0 ? conf_shell : argv[0]);
return -1;
} else
LOG_DBG("%s: successfully started", conf_shell);

View file

@ -61,7 +61,7 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[],
LOG_ERRNO("failed to read from pipe");
return false;
} else {
LOG_ERRNO_P("%s: failed to spawn", _errno, argv[0]);
LOG_ERRNO_P(_errno, "%s: failed to spawn", argv[0]);
errno = _errno;
waitpid(pid, NULL, 0);
return false;

View file

@ -140,7 +140,7 @@ fdm_ptmx_out(struct fdm *fdm, int fd, int events, void *data)
}
#if PTMX_TIMING
static struct timespec last = {};
static struct timespec last = {0};
#endif
static bool
@ -339,7 +339,7 @@ fdm_blink(struct fdm *fdm, int fd, int events, void *data)
term->blink.active = false;
term->blink.state = BLINK_ON;
static const struct itimerspec disarm = {};
static const struct itimerspec disarm = {{0}};
if (timerfd_settime(term->blink.fd, 0, &disarm, NULL) < 0)
LOG_ERRNO("failed to disarm blink timer");
} else
@ -437,11 +437,11 @@ fdm_delayed_render(struct fdm *fdm, int fd, int events, void *data)
return true;
#if PTMX_TIMING
last = (struct timespec){};
last = (struct timespec){0};
#endif
/* Reset timers */
struct itimerspec reset = {};
struct itimerspec reset = {{0}};
timerfd_settime(term->delayed_render_timer.lower_fd, 0, &reset, NULL);
timerfd_settime(term->delayed_render_timer.upper_fd, 0, &reset, NULL);
term->delayed_render_timer.is_armed = false;
@ -707,7 +707,7 @@ reload_fonts(struct terminal *term)
{count, (const char **)names, attrs3, &fonts[3]},
};
thrd_t tids[4] = {};
thrd_t tids[4] = {0};
for (size_t i = 0; i < 4; i++) {
int ret = thrd_create(&tids[i], &font_loader_thread, &data[i]);
if (ret != thrd_success) {
@ -1709,7 +1709,7 @@ cursor_blink_start_timer(struct terminal *term)
static bool
cursor_blink_stop_timer(struct terminal *term)
{
return timerfd_settime(term->cursor_blink.fd, 0, &(struct itimerspec){}, NULL) == 0;
return timerfd_settime(term->cursor_blink.fd, 0, &(struct itimerspec){{0}}, NULL) == 0;
}
void
@ -2279,10 +2279,10 @@ term_enable_app_sync_updates(struct terminal *term)
/* Disarm delayed rendering timers */
timerfd_settime(
term->delayed_render_timer.lower_fd, 0,
&(struct itimerspec){}, NULL);
&(struct itimerspec){{0}}, NULL);
timerfd_settime(
term->delayed_render_timer.upper_fd, 0,
&(struct itimerspec){}, NULL);
&(struct itimerspec){{0}}, NULL);
term->delayed_render_timer.is_armed = false;
}
@ -2299,7 +2299,7 @@ term_disable_app_sync_updates(struct terminal *term)
/* Reset timers */
timerfd_settime(
term->render.app_sync_updates.timer_fd, 0,
&(struct itimerspec){}, NULL);
&(struct itimerspec){{0}}, NULL);
}
static inline void

9
vt.c
View file

@ -734,6 +734,11 @@ action_utf8_44(struct terminal *term, uint8_t c)
action_utf8_print(term, term->vt.utf8);
}
#if defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
static enum state
state_ground_switch(struct terminal *term, uint8_t data)
{
@ -1256,6 +1261,10 @@ state_utf8_43_switch(struct terminal *term, uint8_t data)
}
}
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif
void
vt_from_slave(struct terminal *term, const uint8_t *data, size_t len)
{