Do not check xfree argument for NULL

xfree itself checks for NULL, and even this is not necessary
as passing NULL to free(3) is safe.

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Mikhail Gusarov 2010-01-02 05:43:26 +06:00 committed by Keith Packard
parent 15bc35c6e4
commit 2c85d72fc7
11 changed files with 57 additions and 98 deletions

View File

@ -1074,8 +1074,7 @@ MouseInit (KdPointerInfo *pi)
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
pi->nAxes = 3;
pi->nButtons = 32;
if (pi->name)
xfree(pi->name);
xfree(pi->name);
pi->name = strdup("Xephyr virtual mouse");
ephyrMouse = pi;
return Success;
@ -1125,8 +1124,7 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
}
ki->minScanCode = ephyrKeySyms.minKeyCode;
ki->maxScanCode = ephyrKeySyms.maxKeyCode;
if (ki->name)
xfree(ki->name);
xfree(ki->name);
ki->name = strdup("Xephyr virtual keyboard");
ephyrKbd = ki;
return Success;

View File

@ -440,10 +440,9 @@ ephyrDRIClipNotify (WindowPtr a_win,
is_ok = TRUE ;
out:
if (rects) {
xfree (rects) ;
rects = NULL ;
}
xfree (rects) ;
rects = NULL ;
EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
/*do cleanup here*/
}
@ -566,10 +565,9 @@ EphyrDuplicateVisual (unsigned int a_screen,
is_ok = TRUE ;
out:
if (new_visuals) {
xfree (new_visuals) ;
new_visuals = NULL ;
}
xfree (new_visuals) ;
new_visuals = NULL ;
EPHYR_LOG ("leave\n") ;
return is_ok ;
}
@ -1254,10 +1252,9 @@ ProcXF86DRIGetDrawableInfo (register ClientPtr client)
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
(char *)backClipRects);
}
if (clipRects) {
xfree(clipRects);
clipRects = NULL ;
}
xfree(clipRects);
clipRects = NULL ;
EPHYR_LOG ("leave\n") ;
return (client->noClientException);

View File

@ -243,10 +243,9 @@ ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl,
out:
EPHYR_LOG ("leave\n") ;
if (props_buf) {
xfree (props_buf) ;
props_buf = NULL ;
}
xfree (props_buf) ;
props_buf = NULL ;
return res ;
}
@ -301,10 +300,9 @@ ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
out:
EPHYR_LOG ("leave\n") ;
if (props_buf) {
xfree (props_buf) ;
props_buf = NULL ;
}
xfree (props_buf) ;
props_buf = NULL ;
return res ;
}
@ -391,14 +389,12 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
out:
EPHYR_LOG ("leave\n") ;
if (server_string) {
xfree (server_string) ;
server_string = NULL;
}
if (buf) {
xfree (buf);
buf = NULL;
}
xfree (server_string) ;
server_string = NULL;
xfree (buf);
buf = NULL;
return res ;
}

View File

@ -485,10 +485,8 @@ ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
if (!a_encodings)
return ;
for (i=0; i < a_num_encodings; i++) {
if (a_encodings[i].name) {
xfree (a_encodings[i].name) ;
a_encodings[i].name = NULL ;
}
xfree (a_encodings[i].name) ;
a_encodings[i].name = NULL ;
}
xfree (a_encodings) ;
}

View File

@ -371,10 +371,8 @@ ephyrXVPrivDelete (EphyrXVPriv *a_this)
ephyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
a_this->host_adaptors = NULL ;
}
if (a_this->adaptors) {
xfree (a_this->adaptors) ;
a_this->adaptors = NULL ;
}
xfree (a_this->adaptors) ;
a_this->adaptors = NULL ;
xfree (a_this) ;
EPHYR_LOG ("leave\n") ;
}
@ -675,14 +673,11 @@ ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
is_ok = TRUE ;
out:
if (registered_adaptors) {
xfree (registered_adaptors) ;
registered_adaptors = NULL ;
}
if (adaptors) {
xfree (adaptors) ;
adaptors=NULL ;
}
xfree (registered_adaptors) ;
registered_adaptors = NULL ;
xfree (adaptors) ;
adaptors = NULL ;
EPHYR_LOG ("leave\n") ;
return is_ok ;
}

View File

@ -457,9 +457,8 @@ void
fakeCardFini (KdCardInfo *card)
{
FakePriv *priv = card->driver;
if (priv->base)
free (priv->base);
free (priv->base);
xfree (priv);
}

View File

@ -75,8 +75,7 @@ BusInit (KdPointerInfo *pi)
if ((fd = open (BusNames[i], 0)) >= 0)
{
close(fd);
if (pi->path)
xfree(pi->path);
xfree(pi->path);
pi->path = strdup(BusNames[i]);
return Success;
}

View File

@ -737,11 +737,9 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
if (!ki)
return !Success;
if (ki->path)
xfree(ki->path);
xfree(ki->path);
ki->path = strdup("console");
if (ki->name)
xfree(ki->name);
xfree(ki->name);
ki->name = strdup("Linux console keyboard");
readKernelMapping (ki);

View File

@ -175,10 +175,8 @@ TslibInit (KdPointerInfo *pi)
static void
TslibFini (KdPointerInfo *pi)
{
if (pi->driverPrivate) {
xfree(pi->driverPrivate);
pi->driverPrivate = NULL;
}
xfree(pi->driverPrivate);
pi->driverPrivate = NULL;
}

View File

@ -138,40 +138,28 @@ KdFreePointer(KdPointerInfo *pi)
{
InputOption *option, *prev = NULL;
if (pi->name)
xfree(pi->name);
if (pi->path)
xfree(pi->path);
xfree(pi->name);
xfree(pi->path);
for (option = pi->options; option; option = option->next) {
if (prev)
xfree(prev);
if (option->key)
xfree(option->key);
if (option->value)
xfree(option->value);
xfree(prev);
xfree(option->key);
xfree(option->value);
prev = option;
}
if (prev)
xfree(prev);
xfree(prev);
xfree(pi);
}
void
KdFreeKeyboard(KdKeyboardInfo *ki)
{
if (ki->name)
xfree(ki->name);
if (ki->path)
xfree(ki->path);
if (ki->xkbRules)
xfree(ki->xkbRules);
if (ki->xkbModel)
xfree(ki->xkbModel);
if (ki->xkbLayout)
xfree(ki->xkbLayout);
xfree(ki->name);
xfree(ki->path);
xfree(ki->xkbRules);
xfree(ki->xkbModel);
xfree(ki->xkbLayout);
ki->next = NULL;
xfree(ki);
}

View File

@ -247,20 +247,18 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
{
int i;
if(pAdaptor->name)
xfree(pAdaptor->name);
xfree(pAdaptor->name);
if(pAdaptor->pEncodings) {
XvEncodingPtr pEncode = pAdaptor->pEncodings;
for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
if(pEncode->name) xfree(pEncode->name);
xfree(pEncode->name);
}
xfree(pAdaptor->pEncodings);
}
if(pAdaptor->pFormats)
xfree(pAdaptor->pFormats);
xfree(pAdaptor->pFormats);
if(pAdaptor->pPorts) {
XvPortPtr pPort = pAdaptor->pPorts;
@ -283,17 +281,15 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
XvAttributePtr pAttribute = pAdaptor->pAttributes;
for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
if(pAttribute->name) xfree(pAttribute->name);
xfree(pAttribute->name);
}
xfree(pAdaptor->pAttributes);
}
if(pAdaptor->nImages)
xfree(pAdaptor->pImages);
xfree(pAdaptor->pImages);
if(pAdaptor->devPriv.ptr)
xfree(pAdaptor->devPriv.ptr);
xfree(pAdaptor->devPriv.ptr);
}
static Bool
@ -1157,12 +1153,9 @@ KdXVCloseScreen(int i, ScreenPtr pScreen)
KdXVFreeAdaptor(pa);
}
if(pxvs->pAdaptors)
xfree(pxvs->pAdaptors);
xfree(pxvs->pAdaptors);
xfree(ScreenPriv);
return TRUE;
}