[PATCH 2/2] Remove more superfluous if(p!=NULL) checks around free(p).
Cyril Brulebois
kibi at debian.org
Mon Nov 8 14:35:33 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>
---
dix/grabs.c | 7 ++-----
glx/single2.c | 3 +--
hw/xfree86/modes/xf86Crtc.c | 3 +--
mi/mispans.c | 2 +-
miext/rootless/rootlessScreen.c | 3 +--
os/log.c | 6 ++----
xkb/XKBMAlloc.c | 6 ++----
xkb/ddxLoad.c | 6 ++----
8 files changed, 12 insertions(+), 24 deletions(-)
diff --git a/dix/grabs.c b/dix/grabs.c
index f850e3d..69c58df 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -117,11 +117,8 @@ CreateGrab(
static void
FreeGrab(GrabPtr pGrab)
{
- if (pGrab->modifiersDetail.pMask != NULL)
- free(pGrab->modifiersDetail.pMask);
-
- if (pGrab->detail.pMask != NULL)
- free(pGrab->detail.pMask);
+ free(pGrab->modifiersDetail.pMask);
+ free(pGrab->detail.pMask);
if (pGrab->cursor)
FreeCursor(pGrab->cursor, (Cursor)0);
diff --git a/glx/single2.c b/glx/single2.c
index 56ad86d..f93ce6e 100644
--- a/glx/single2.c
+++ b/glx/single2.c
@@ -377,8 +377,7 @@ int DoGetString(__GLXclientState *cl, GLbyte *pc, GLboolean need_swap)
__GLX_SEND_HEADER();
WriteToClient(client, length, (char *) string);
- if (buf != NULL)
- free(buf);
+ free(buf);
return Success;
}
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index b2daec7..7fc2a60 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2964,8 +2964,7 @@ xf86OutputSetEDID (xf86OutputPtr output, xf86MonPtr edid_mon)
int size;
#endif
- if (output->MonInfo != NULL)
- free(output->MonInfo);
+ free(output->MonInfo);
output->MonInfo = edid_mon;
diff --git a/mi/mispans.c b/mi/mispans.c
index 9f56e3c..53539e5 100644
--- a/mi/mispans.c
+++ b/mi/mispans.c
@@ -215,7 +215,7 @@ void miAppendSpans(SpanGroup *spanGroup, SpanGroup *otherGroup, Spans *spans)
void miFreeSpanGroup(SpanGroup *spanGroup)
{
- if (spanGroup->group != NULL) free(spanGroup->group);
+ free(spanGroup->group);
}
static void QuickSortSpansX(
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 43b9cbb..61d2f5d 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -92,8 +92,7 @@ RootlessUpdateScreenPixmap(ScreenPtr pScreen)
rowbytes = PixmapBytePad(pScreen->width, pScreen->rootDepth);
if (s->pixmap_data_size < rowbytes) {
- if (s->pixmap_data != NULL)
- free(s->pixmap_data);
+ free(s->pixmap_data);
s->pixmap_data_size = rowbytes;
s->pixmap_data = malloc(s->pixmap_data_size);
diff --git a/os/log.c b/os/log.c
index ee4b45f..7d10783 100644
--- a/os/log.c
+++ b/os/log.c
@@ -489,8 +489,7 @@ AuditFlush(OsTimerPtr timer, CARD32 now, pointer arg)
ErrorF("%slast message repeated %d times\n",
prefix != NULL ? prefix : "", nrepeat);
nrepeat = 0;
- if (prefix != NULL)
- free(prefix);
+ free(prefix);
return AUDIT_TIMEOUT;
} else {
/* if the timer expires without anything to print, flush the message */
@@ -523,8 +522,7 @@ VAuditF(const char *f, va_list args)
nrepeat = 0;
auditTimer = TimerSet(auditTimer, 0, AUDIT_TIMEOUT, AuditFlush, NULL);
}
- if (prefix != NULL)
- free(prefix);
+ free(prefix);
}
void
diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index 6b186c1..e9afe31 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -292,11 +292,9 @@ KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
}
type= &xkb->map->types[type_ndx];
if (map_count==0) {
- if (type->map!=NULL)
- free(type->map);
+ free(type->map);
type->map= NULL;
- if (type->preserve!=NULL)
- free(type->preserve);
+ free(type->preserve);
type->preserve= NULL;
type->map_count= 0;
}
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 5e6ab87..cfc6198 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -267,8 +267,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
strncpy(nameRtrn,keymap,nameRtrnLen);
nameRtrn[nameRtrnLen-1]= '\0';
}
- if (buf != NULL)
- free(buf);
+ free(buf);
return TRUE;
}
else
@@ -287,8 +286,7 @@ XkbDDXCompileKeymapByNames( XkbDescPtr xkb,
}
if (nameRtrn)
nameRtrn[0]= '\0';
- if (buf != NULL)
- free(buf);
+ free(buf);
return FALSE;
}
--
1.7.2.3
More information about the xorg-devel
mailing list