don't use empty struct initializers

This commit is contained in:
Daniel Eklöf 2020-08-23 07:42:20 +02:00
parent ddef95c297
commit dabdffafa5
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
7 changed files with 27 additions and 27 deletions

View file

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

View file

@ -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;
}
@ -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)
@ -1544,7 +1544,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;

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

@ -325,7 +325,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 +452,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 +647,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);
}

View file

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

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