diff options
author | Mikhail Gusarov <dottedmag@dottedmag.net> | 2010-06-06 15:28:30 +0700 |
---|---|---|
committer | Mikhail Gusarov <dottedmag@dottedmag.net> | 2010-06-06 20:27:18 +0700 |
commit | 0a4d8cbdcd7b25313fb29ccdb498044af95f7de6 (patch) | |
tree | 3534c9035180b7e0d2ebbbf0202a370cb61f8e8d /dix | |
parent | 5a0fc0ad21d562612676ef88ef2d533b2391810a (diff) |
Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:
@@
expression E;
@@
-if(E) { free(E); }
+free(E);
Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'dix')
-rw-r--r-- | dix/colormap.c | 12 | ||||
-rw-r--r-- | dix/devices.c | 15 | ||||
-rw-r--r-- | dix/dispatch.c | 4 | ||||
-rw-r--r-- | dix/dixfonts.c | 14 | ||||
-rw-r--r-- | dix/dixutils.c | 2 | ||||
-rw-r--r-- | dix/events.c | 12 | ||||
-rw-r--r-- | dix/getevents.c | 3 | ||||
-rw-r--r-- | dix/grabs.c | 8 | ||||
-rw-r--r-- | dix/region.c | 3 |
9 files changed, 29 insertions, 44 deletions
diff --git a/dix/colormap.c b/dix/colormap.c index d530830ac..ae9069066 100644 --- a/dix/colormap.c +++ b/dix/colormap.c @@ -1639,8 +1639,7 @@ AllocColorCells (int client, ColormapPtr pmap, int colors, int planes, pcr->client = client; if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) ok = BadAlloc; - } else if (pcr) - free(pcr); + } else free(pcr); return (ok); } @@ -1730,8 +1729,7 @@ AllocColorPlanes (int client, ColormapPtr pmap, int colors, pcr->client = client; if (!AddResource(FakeClientID(client), RT_CMAPENTRY, (pointer)pcr)) ok = BadAlloc; - } else if (pcr) - free(pcr); + } else free(pcr); return (ok); } @@ -1764,9 +1762,9 @@ AllocDirect (int client, ColormapPtr pmap, int c, int r, int g, int b, Bool cont ppixBlue = malloc(npixB * sizeof(Pixel)); if (!ppixRed || !ppixGreen || !ppixBlue) { - if (ppixBlue) free(ppixBlue); - if (ppixGreen) free(ppixGreen); - if (ppixRed) free(ppixRed); + free(ppixBlue); + free(ppixGreen); + free(ppixRed); return(BadAlloc); } diff --git a/dix/devices.c b/dix/devices.c index 427264d46..8f9c8ffff 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -740,8 +740,7 @@ FreeDeviceClass(int type, pointer *class) case ButtonClass: { ButtonClassPtr *b = (ButtonClassPtr*)class; - if ((*b)->xkb_acts) - free((*b)->xkb_acts); + free((*b)->xkb_acts); free((*b)); break; } @@ -749,8 +748,7 @@ FreeDeviceClass(int type, pointer *class) { ValuatorClassPtr *v = (ValuatorClassPtr*)class; - if ((*v)->motion) - free((*v)->motion); + free((*v)->motion); free((*v)); break; } @@ -1465,10 +1463,8 @@ InitStringFeedbackClassDeviceStruct ( feedc->ctrl.symbols_displayed = malloc(sizeof (KeySym) * max_symbols); if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) { - if (feedc->ctrl.symbols_supported) - free(feedc->ctrl.symbols_supported); - if (feedc->ctrl.symbols_displayed) - free(feedc->ctrl.symbols_displayed); + free(feedc->ctrl.symbols_supported); + free(feedc->ctrl.symbols_displayed); free(feedc); return FALSE; } @@ -2283,8 +2279,7 @@ ProcGetMotionEvents(ClientPtr client) WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord), (char *)coords); } - if (coords) - free(coords); + free(coords); return Success; } diff --git a/dix/dispatch.c b/dix/dispatch.c index 79bdb552b..44164f292 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -2837,7 +2837,7 @@ ProcQueryColors(ClientPtr client) return(BadAlloc); if( (rc = QueryColors(pcmp, count, (Pixel *)&stuff[1], prgbs, client)) ) { - if (prgbs) free(prgbs); + free(prgbs); return rc; } memset(&qcr, 0, sizeof(xQueryColorsReply)); @@ -2851,7 +2851,7 @@ ProcQueryColors(ClientPtr client) client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend; WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs); } - if (prgbs) free(prgbs); + free(prgbs); return Success; } diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 51c7ab64c..e32117748 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -677,7 +677,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) return TRUE; } if (err == FontNameAlias) { - if (resolved) free(resolved); + free(resolved); resolved = malloc(resolvedlen + 1); if (resolved) memmove(resolved, tmpname, resolvedlen + 1); @@ -731,8 +731,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) { c->saved = c->current; c->haveSaved = TRUE; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); @@ -828,10 +827,10 @@ bail: for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); FreeFontNames(names); free(c); - if (resolved) free(resolved); + free(resolved); return TRUE; } @@ -994,8 +993,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) c->saved = c->current; c->haveSaved = TRUE; c->savedNumFonts = numFonts; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); @@ -1106,7 +1104,7 @@ bail: FreeFPE(c->fpe_list[i]); free(c->reply); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); free(c); return TRUE; } diff --git a/dix/dixutils.c b/dix/dixutils.c index 51dbd1481..cb1c97c8f 100644 --- a/dix/dixutils.c +++ b/dix/dixutils.c @@ -893,7 +893,7 @@ InitCallbackManager(void) { DeleteCallbackList(listsToCleanup[i]); } - if (listsToCleanup) free(listsToCleanup); + free(listsToCleanup); numCallbackListsToCleanup = 0; listsToCleanup = NULL; diff --git a/dix/events.c b/dix/events.c index 1be212f33..2dc0e9821 100644 --- a/dix/events.c +++ b/dix/events.c @@ -3793,10 +3793,8 @@ DeliverFocusedEvent(DeviceIntPtr keybd, InternalEvent *event, WindowPtr window) } unwind: - if (xE) - free(xE); - if (xi2) - free(xi2); + free(xE); + free(xi2); return; } @@ -3976,10 +3974,8 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev, } } - if (xi) - free(xi); - if (xi2) - free(xi2); + free(xi); + free(xi2); } /* This function is used to set the key pressed or key released state - diff --git a/dix/getevents.c b/dix/getevents.c index 3892f6fb2..f9d65e970 100644 --- a/dix/getevents.c +++ b/dix/getevents.c @@ -327,8 +327,7 @@ void AllocateMotionHistory(DeviceIntPtr pDev) { int size; - if (pDev->valuator->motion) - free(pDev->valuator->motion); + free(pDev->valuator->motion); if (pDev->valuator->numMotionEvents < 1) return; diff --git a/dix/grabs.c b/dix/grabs.c index 2931631c0..f850e3d84 100644 --- a/dix/grabs.c +++ b/dix/grabs.c @@ -441,10 +441,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab) details = malloc(i * sizeof(Mask *)); if (!deletes || !adds || !updates || !details) { - if (details) free(details); - if (updates) free(updates); - if (adds) free(adds); - if (deletes) free(deletes); + free(details); + free(updates); + free(adds); + free(deletes); return FALSE; } diff --git a/dix/region.c b/dix/region.c index 911fe1614..a77d17b30 100644 --- a/dix/region.c +++ b/dix/region.c @@ -762,8 +762,7 @@ RegionOp( AppendRegions(newReg, r2BandEnd, r2End); } - if (oldData) - free(oldData); + free(oldData); if (!(numRects = newReg->data->numRects)) { |