[PATCH weston v6 65/73] compositor-drm: no need to clear inherited_mode

Pekka Paalanen ppaalanen at gmail.com
Fri Feb 16 14:57:50 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

The head was just zalloc()'d, there is no need to memset it to zero.

If a function fails, it is preferable it leaves the output arguments
untouched.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-drm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 352bd17b..8dfe2baf 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -4698,7 +4698,6 @@ drm_output_choose_initial_mode(struct drm_backend *backend,
 static int
 drm_head_read_current_setup(struct drm_head *head, struct drm_backend *backend)
 {
-	drmModeModeInfo *mode = &head->inherited_mode;
 	int drm_fd = backend->drm.fd;
 	drmModeEncoder *encoder;
 	drmModeCrtc *crtc;
@@ -4706,14 +4705,13 @@ drm_head_read_current_setup(struct drm_head *head, struct drm_backend *backend)
 	/* Get the current mode on the crtc that's currently driving
 	 * this connector. */
 	encoder = drmModeGetEncoder(drm_fd, head->connector->encoder_id);
-	memset(mode, 0, sizeof *mode);
 	if (encoder != NULL) {
 		crtc = drmModeGetCrtc(drm_fd, encoder->crtc_id);
 		drmModeFreeEncoder(encoder);
 		if (crtc == NULL)
 			return -1;
 		if (crtc->mode_valid)
-			*mode = crtc->mode;
+			head->inherited_mode = crtc->mode;
 		drmModeFreeCrtc(crtc);
 	}
 
@@ -5257,7 +5255,7 @@ drm_head_create(struct drm_backend *backend, uint32_t connector_id,
 	if (drm_head_read_current_setup(head, backend) < 0) {
 		weston_log("Failed to retrieve current mode from connector %d.\n",
 			   head->connector_id);
-		/* Continue, inherited_mode was memset to zero. */
+		/* Not fatal. */
 	}
 
 	weston_compositor_add_head(backend->compositor, &head->base);
-- 
2.13.6



More information about the wayland-devel mailing list