diff options
author | Simon Ser <contact@emersion.fr> | 2023-07-07 14:34:56 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-07-07 17:31:11 +0200 |
commit | 7a9f8d8d6bf72fcea210552b7bec9b99f342f857 (patch) | |
tree | c84c622b9ea25646c081f81b534ec7c70b84ac84 /backend | |
parent | 4966857f211cb6f48852928076a59f16aadb742b (diff) |
Use struct initializers instead of memset()
This is a bit more type-safe.
Diffstat (limited to 'backend')
-rw-r--r-- | backend/backend.c | 5 | ||||
-rw-r--r-- | backend/drm/atomic.c | 2 | ||||
-rw-r--r-- | backend/drm/drm.c | 13 | ||||
-rw-r--r-- | backend/drm/renderer.c | 2 |
4 files changed, 12 insertions, 10 deletions
diff --git a/backend/backend.c b/backend/backend.c index c6afe14b..125ed411 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -40,8 +40,9 @@ void wlr_backend_init(struct wlr_backend *backend, const struct wlr_backend_impl *impl) { - memset(backend, 0, sizeof(*backend)); - backend->impl = impl; + *backend = (struct wlr_backend){ + .impl = impl, + }; wl_signal_init(&backend->events.destroy); wl_signal_init(&backend->events.new_input); wl_signal_init(&backend->events.new_output); diff --git a/backend/drm/atomic.c b/backend/drm/atomic.c index 7c5fc0ba..c2005f96 100644 --- a/backend/drm/atomic.c +++ b/backend/drm/atomic.c @@ -50,7 +50,7 @@ struct atomic { }; static void atomic_begin(struct atomic *atom) { - memset(atom, 0, sizeof(*atom)); + *atom = (struct atomic){0}; atom->req = drmModeAtomicAlloc(); if (!atom->req) { diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 8c639379..5f71f923 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -445,11 +445,12 @@ static bool drm_crtc_commit(struct wlr_drm_connector *conn, static void drm_connector_state_init(struct wlr_drm_connector_state *state, struct wlr_drm_connector *conn, const struct wlr_output_state *base) { - memset(state, 0, sizeof(*state)); - state->base = base; - state->modeset = base->allow_artifacts; - state->active = (base->committed & WLR_OUTPUT_STATE_ENABLED) ? - base->enabled : conn->output.enabled; + *state = (struct wlr_drm_connector_state){ + .base = base, + .modeset = base->allow_artifacts, + .active = (base->committed & WLR_OUTPUT_STATE_ENABLED) ? + base->enabled : conn->output.enabled, + }; if (base->committed & WLR_OUTPUT_STATE_MODE) { switch (base->mode_type) { @@ -1028,7 +1029,7 @@ static void drm_connector_destroy_output(struct wlr_output *output) { free(mode); } - memset(&conn->output, 0, sizeof(struct wlr_output)); + conn->output = (struct wlr_output){0}; } static const struct wlr_drm_format_set *drm_connector_get_cursor_formats( diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 56468960..f98cc869 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -55,7 +55,7 @@ static void finish_drm_surface(struct wlr_drm_surface *surf) { wlr_swapchain_destroy(surf->swapchain); - memset(surf, 0, sizeof(*surf)); + *surf = (struct wlr_drm_surface){0}; } bool init_drm_surface(struct wlr_drm_surface *surf, |