Use struct initializers instead of memset()

This is a bit more type-safe.
This commit is contained in:
Simon Ser 2023-07-07 14:34:56 +02:00
parent 4966857f21
commit 7a9f8d8d6b
34 changed files with 134 additions and 113 deletions

View file

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

View file

@ -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(

View file

@ -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,