[PATCH 1/2] Eliminate redundant data parameter from drmmode_crtc_scanout_create

Michel Dänzer michel at daenzer.net
Tue Oct 13 02:59:29 PDT 2015


From: Michel Dänzer <michel.daenzer at amd.com>

drmmode_crtc_scanout_create just needs to call
drmmode_crtc_scanout_allocate when scanout->bo is NULL.

This makes it clearer to the reader / compiler that
drmmode_crtc_scanout_create doesn't dereference scanout->bo when it's
NULL.

Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
 src/drmmode_display.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 94f273c..f010919 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -513,7 +513,7 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,
 static PixmapPtr
 drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
 			    struct drmmode_scanout *scanout,
-			    void *data, int width, int height)
+			    int width, int height)
 {
 	ScrnInfoPtr pScrn = crtc->scrn;
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
@@ -527,9 +527,8 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc,
 		drmmode_crtc_scanout_destroy(drmmode, scanout);
 	}
 
-	if (!data) {
-		data = drmmode_crtc_scanout_allocate(crtc, scanout, width, height);
-		if (!data)
+	if (!scanout->bo) {
+		if (!drmmode_crtc_scanout_allocate(crtc, scanout, width, height))
 			return NULL;
 	}
 
@@ -656,7 +655,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 			for (i = 0; i < (info->tear_free ? 2 : 1); i++) {
 				drmmode_crtc_scanout_create(crtc,
 							    &drmmode_crtc->scanout[i],
-							    NULL, mode->HDisplay,
+							    mode->HDisplay,
 							    mode->VDisplay);
 
 				if (drmmode_crtc->scanout[i].pixmap) {
@@ -819,8 +818,11 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-	return drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, data,
-					   width, height);
+	/* Xorg passes in the return value of drmmode_crtc_shadow_allocate
+	 * for data, but that's redundant for drmmode_crtc_scanout_create.
+	 */
+	return drmmode_crtc_scanout_create(crtc, &drmmode_crtc->rotate, width,
+					   height);
 }
 
 static void
-- 
2.6.0



More information about the xorg-driver-ati mailing list