aboutsummaryrefslogtreecommitdiff
path: root/backend/drm
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-07-07 14:34:56 +0200
committerSimon Ser <contact@emersion.fr>2023-07-07 17:31:11 +0200
commit7a9f8d8d6bf72fcea210552b7bec9b99f342f857 (patch)
treec84c622b9ea25646c081f81b534ec7c70b84ac84 /backend/drm
parent4966857f211cb6f48852928076a59f16aadb742b (diff)
Use struct initializers instead of memset()
This is a bit more type-safe.
Diffstat (limited to 'backend/drm')
-rw-r--r--backend/drm/atomic.c2
-rw-r--r--backend/drm/drm.c13
-rw-r--r--backend/drm/renderer.c2
3 files changed, 9 insertions, 8 deletions
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,