[PATCH] Remove more superfluous if(p!=NULL) checks around free(p).

Cyril Brulebois kibi at debian.org
Wed Nov 10 06:28:29 PST 2010


This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@
- if (E != NULL) {
-   free(E);
- }
+ free(E);

Signed-off-by: Cyril Brulebois <kibi at debian.org>
---
 glx/glxdri.c           |    4 +---
 glx/glxdri2.c          |    4 +---
 glx/single2.c          |    4 +---
 hw/xwin/glx/indirect.c |    5 +----
 4 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/glx/glxdri.c b/glx/glxdri.c
index 41482c9..ec93434 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -1160,9 +1160,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
      */
     buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
     if (buffer_size > 0) {
-	if (screen->base.GLXextensions != NULL) {
-	    free(screen->base.GLXextensions);
-	}
+	free(screen->base.GLXextensions);
 
 	screen->base.GLXextensions = xnfalloc(buffer_size);
 	(void) __glXGetExtensionString(screen->glx_enable_bits, 
diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index c2305ad..0b69201 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -792,9 +792,7 @@ __glXDRIscreenProbe(ScreenPtr pScreen)
      */
     buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
     if (buffer_size > 0) {
-	if (screen->base.GLXextensions != NULL) {
-	    free(screen->base.GLXextensions);
-	}
+	free(screen->base.GLXextensions);
 
 	screen->base.GLXextensions = xnfalloc(buffer_size);
 	(void) __glXGetExtensionString(screen->glx_enable_bits, 
diff --git a/glx/single2.c b/glx/single2.c
index f93ce6e..07b89a8 100644
--- a/glx/single2.c
+++ b/glx/single2.c
@@ -346,9 +346,7 @@ int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
 				      cl->GLClientextensions);
 	buf = __glXcombine_strings(buf1,
 				      cx->pGlxScreen->GLextensions);
-	if (buf1 != NULL) {
-	    free(buf1);
-	}
+	free(buf1);
 	string = buf;
     }
     else if ( name == GL_VERSION ) {
diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 3891885..5d7391d 100644
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -682,10 +682,7 @@ glxWinScreenProbe(ScreenPtr pScreen)
         unsigned int buffer_size = __glXGetExtensionString(screen->glx_enable_bits, NULL);
         if (buffer_size > 0)
           {
-            if (screen->base.GLXextensions != NULL)
-              {
-                free(screen->base.GLXextensions);
-              }
+            free(screen->base.GLXextensions);
 
             screen->base.GLXextensions = xnfalloc(buffer_size);
             __glXGetExtensionString(screen->glx_enable_bits, screen->base.GLXextensions);
-- 
1.7.2.3



More information about the xorg-devel mailing list