From 6c350799b22ddc5cb89467c95692437bbf0116b9 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 26 Apr 2022 09:43:54 +0200 Subject: Zero-initialize structs in init functions Ensures there is no field left to its previous undefined value after calling an init function. --- backend/backend.c | 2 +- backend/drm/drm.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/backend.c b/backend/backend.c index bfb43ba0..ac6e2165 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -36,7 +36,7 @@ void wlr_backend_init(struct wlr_backend *backend, const struct wlr_backend_impl *impl) { - assert(backend); + memset(backend, 0, sizeof(*backend)); backend->impl = impl; wl_signal_init(&backend->events.destroy); wl_signal_init(&backend->events.new_input); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 2b573295..5a828426 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -380,6 +380,7 @@ static bool drm_crtc_page_flip(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->committed & (WLR_OUTPUT_STATE_ENABLED | WLR_OUTPUT_STATE_MODE); -- cgit v1.2.3