[PATCH xf86-video-mga 2/4] Remove if(E != NULL) checks around free(E)

Matt Turner mattst88 at gmail.com
Mon Sep 26 19:41:50 PDT 2011


Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
 src/mga_dri.c    |   24 ++++++++----------------
 src/mga_driver.c |   20 ++++++--------------
 src/mga_merge.c  |    6 ++----
 src/mga_video.c  |    3 +--
 4 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/src/mga_dri.c b/src/mga_dri.c
index 957c6df..1454994 100644
--- a/src/mga_dri.c
+++ b/src/mga_dri.c
@@ -1011,8 +1011,8 @@ static void MGADRIMoveBuffersXAA(WindowPtr pParent, DDXPointRec ptOldOrg,
 	    pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec)*nbox);
 	    pptNew2 = (DDXPointPtr)malloc(sizeof(DDXPointRec)*nbox);
 	    if (!pboxNew2 || !pptNew2) {
-	        if (pptNew2) free(pptNew2);
-	        if (pboxNew2) free(pboxNew2);
+	        free(pptNew2);
+	        free(pboxNew2);
 	        if (pboxNew1) {
 		    free(pptNew1);
 		    free(pboxNew1);
@@ -1494,21 +1494,13 @@ void MGADRICloseScreen( ScreenPtr pScreen )
    DRICloseScreen( pScreen );
 
    if ( pMga->pDRIInfo ) {
-      if ( pMga->pDRIInfo->devPrivate ) {
-	 free( pMga->pDRIInfo->devPrivate );
-	 pMga->pDRIInfo->devPrivate = 0;
-      }
+      free(pMga->pDRIInfo->devPrivate);
+      pMga->pDRIInfo->devPrivate = 0;
       DRIDestroyInfoRec( pMga->pDRIInfo );
       pMga->pDRIInfo = 0;
    }
-   if ( pMga->DRIServerInfo ) {
-      free(pMga->DRIServerInfo);
-      pMga->DRIServerInfo = 0;
-   }
-   if ( pMga->pVisualConfigs ) {
-      free(pMga->pVisualConfigs);
-   }
-   if ( pMga->pVisualConfigsPriv ) {
-      free( pMga->pVisualConfigsPriv );
-   }
+   free(pMga->DRIServerInfo);
+   pMga->DRIServerInfo = 0;
+   free(pMga->pVisualConfigs);
+   free(pMga->pVisualConfigsPriv);
 }
diff --git a/src/mga_driver.c b/src/mga_driver.c
index d4ae346..dcbfabf 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -644,8 +644,6 @@ MGAGetRec(ScrnInfoPtr pScrn)
 void
 MGAFreeRec(ScrnInfoPtr pScrn)
 {
-    if (pScrn->driverPrivate == NULL)
-	return;
     free(pScrn->driverPrivate);
     pScrn->driverPrivate = NULL;
 }
@@ -2430,8 +2428,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
 			      pMga->FbMapSize,
 			      LOOKUP_BEST_REFRESH);
       
-	if (linePitches)
-	   free(linePitches);
+	free(linePitches);
     }
 
     if (i < 1 && pMga->FBDev) {
@@ -3750,16 +3747,11 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
 #endif
     if (pMga->CursorInfoRec)
     	xf86DestroyCursorInfoRec(pMga->CursorInfoRec);
-    if (pMga->ShadowPtr)
-	free(pMga->ShadowPtr);
-    if (pMga->DGAModes)
-	free(pMga->DGAModes);
-    if (pMga->adaptor)
-	free(pMga->adaptor);
-    if (pMga->portPrivate)
-	free(pMga->portPrivate);
-    if (pMga->ScratchBuffer)
-	free(pMga->ScratchBuffer);
+    free(pMga->ShadowPtr);
+    free(pMga->DGAModes);
+    free(pMga->adaptor);
+    free(pMga->portPrivate);
+    free(pMga->ScratchBuffer);
 
     pScrn->vtSema = FALSE;
 
diff --git a/src/mga_merge.c b/src/mga_merge.c
index e3216c9..c1cf2eb 100644
--- a/src/mga_merge.c
+++ b/src/mga_merge.c
@@ -528,8 +528,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
 			      pMga->FbMapSize,
 			      LOOKUP_BEST_REFRESH);
         
-	if (linePitches)
-	   free(linePitches);
+	free(linePitches);
     }
 
 
@@ -892,8 +891,7 @@ MGACloseScreenMerged(int scrnIndex, ScreenPtr pScreen) {
         pScrn1->currentMode = pScrn1->modes;
         do {
             DisplayModePtr p = pScrn1->currentMode->next; 
-            if(pScrn1->currentMode->Private) 
-                free(pScrn1->currentMode->Private);
+            free(pScrn1->currentMode->Private);
             free(pScrn1->currentMode);
             pScrn1->currentMode = p;
         }while( pScrn1->currentMode != pScrn1->modes);
diff --git a/src/mga_video.c b/src/mga_video.c
index 52b2e16..b7f58c5 100644
--- a/src/mga_video.c
+++ b/src/mga_video.c
@@ -145,8 +145,7 @@ void MGAInitVideo(ScreenPtr pScreen)
     if(num_adaptors)
         xf86XVScreenInit(pScreen, adaptors, num_adaptors);
 
-    if(newAdaptors)
-	free(newAdaptors);
+    free(newAdaptors);
 }
 
 /* client libraries expect an encoding */
-- 
1.7.3.4



More information about the xorg-devel mailing list