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:
parent
15bc35c6e4
commit
2c85d72fc7
|
@ -1074,8 +1074,7 @@ MouseInit (KdPointerInfo *pi)
|
||||||
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
|
((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
|
||||||
pi->nAxes = 3;
|
pi->nAxes = 3;
|
||||||
pi->nButtons = 32;
|
pi->nButtons = 32;
|
||||||
if (pi->name)
|
xfree(pi->name);
|
||||||
xfree(pi->name);
|
|
||||||
pi->name = strdup("Xephyr virtual mouse");
|
pi->name = strdup("Xephyr virtual mouse");
|
||||||
ephyrMouse = pi;
|
ephyrMouse = pi;
|
||||||
return Success;
|
return Success;
|
||||||
|
@ -1125,8 +1124,7 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
|
||||||
}
|
}
|
||||||
ki->minScanCode = ephyrKeySyms.minKeyCode;
|
ki->minScanCode = ephyrKeySyms.minKeyCode;
|
||||||
ki->maxScanCode = ephyrKeySyms.maxKeyCode;
|
ki->maxScanCode = ephyrKeySyms.maxKeyCode;
|
||||||
if (ki->name)
|
xfree(ki->name);
|
||||||
xfree(ki->name);
|
|
||||||
ki->name = strdup("Xephyr virtual keyboard");
|
ki->name = strdup("Xephyr virtual keyboard");
|
||||||
ephyrKbd = ki;
|
ephyrKbd = ki;
|
||||||
return Success;
|
return Success;
|
||||||
|
|
|
@ -440,10 +440,9 @@ ephyrDRIClipNotify (WindowPtr a_win,
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (rects) {
|
xfree (rects) ;
|
||||||
xfree (rects) ;
|
rects = NULL ;
|
||||||
rects = NULL ;
|
|
||||||
}
|
|
||||||
EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
|
EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
|
||||||
/*do cleanup here*/
|
/*do cleanup here*/
|
||||||
}
|
}
|
||||||
|
@ -566,10 +565,9 @@ EphyrDuplicateVisual (unsigned int a_screen,
|
||||||
|
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
out:
|
out:
|
||||||
if (new_visuals) {
|
xfree (new_visuals) ;
|
||||||
xfree (new_visuals) ;
|
new_visuals = NULL ;
|
||||||
new_visuals = NULL ;
|
|
||||||
}
|
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
return is_ok ;
|
return is_ok ;
|
||||||
}
|
}
|
||||||
|
@ -1254,10 +1252,9 @@ ProcXF86DRIGetDrawableInfo (register ClientPtr client)
|
||||||
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
|
sizeof(drm_clip_rect_t) * rep.numBackClipRects,
|
||||||
(char *)backClipRects);
|
(char *)backClipRects);
|
||||||
}
|
}
|
||||||
if (clipRects) {
|
xfree(clipRects);
|
||||||
xfree(clipRects);
|
clipRects = NULL ;
|
||||||
clipRects = NULL ;
|
|
||||||
}
|
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
|
|
||||||
return (client->noClientException);
|
return (client->noClientException);
|
||||||
|
|
|
@ -243,10 +243,9 @@ ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
if (props_buf) {
|
xfree (props_buf) ;
|
||||||
xfree (props_buf) ;
|
props_buf = NULL ;
|
||||||
props_buf = NULL ;
|
|
||||||
}
|
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,10 +300,9 @@ ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
|
||||||
|
|
||||||
out:
|
out:
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
if (props_buf) {
|
xfree (props_buf) ;
|
||||||
xfree (props_buf) ;
|
props_buf = NULL ;
|
||||||
props_buf = NULL ;
|
|
||||||
}
|
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,14 +389,12 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
|
||||||
|
|
||||||
out:
|
out:
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
if (server_string) {
|
xfree (server_string) ;
|
||||||
xfree (server_string) ;
|
server_string = NULL;
|
||||||
server_string = NULL;
|
|
||||||
}
|
xfree (buf);
|
||||||
if (buf) {
|
buf = NULL;
|
||||||
xfree (buf);
|
|
||||||
buf = NULL;
|
|
||||||
}
|
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -485,10 +485,8 @@ ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
|
||||||
if (!a_encodings)
|
if (!a_encodings)
|
||||||
return ;
|
return ;
|
||||||
for (i=0; i < a_num_encodings; i++) {
|
for (i=0; i < a_num_encodings; i++) {
|
||||||
if (a_encodings[i].name) {
|
xfree (a_encodings[i].name) ;
|
||||||
xfree (a_encodings[i].name) ;
|
a_encodings[i].name = NULL ;
|
||||||
a_encodings[i].name = NULL ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
xfree (a_encodings) ;
|
xfree (a_encodings) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,10 +371,8 @@ ephyrXVPrivDelete (EphyrXVPriv *a_this)
|
||||||
ephyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
|
ephyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
|
||||||
a_this->host_adaptors = NULL ;
|
a_this->host_adaptors = NULL ;
|
||||||
}
|
}
|
||||||
if (a_this->adaptors) {
|
xfree (a_this->adaptors) ;
|
||||||
xfree (a_this->adaptors) ;
|
a_this->adaptors = NULL ;
|
||||||
a_this->adaptors = NULL ;
|
|
||||||
}
|
|
||||||
xfree (a_this) ;
|
xfree (a_this) ;
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
}
|
}
|
||||||
|
@ -675,14 +673,11 @@ ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
|
||||||
is_ok = TRUE ;
|
is_ok = TRUE ;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (registered_adaptors) {
|
xfree (registered_adaptors) ;
|
||||||
xfree (registered_adaptors) ;
|
registered_adaptors = NULL ;
|
||||||
registered_adaptors = NULL ;
|
xfree (adaptors) ;
|
||||||
}
|
adaptors = NULL ;
|
||||||
if (adaptors) {
|
|
||||||
xfree (adaptors) ;
|
|
||||||
adaptors=NULL ;
|
|
||||||
}
|
|
||||||
EPHYR_LOG ("leave\n") ;
|
EPHYR_LOG ("leave\n") ;
|
||||||
return is_ok ;
|
return is_ok ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,9 +457,8 @@ void
|
||||||
fakeCardFini (KdCardInfo *card)
|
fakeCardFini (KdCardInfo *card)
|
||||||
{
|
{
|
||||||
FakePriv *priv = card->driver;
|
FakePriv *priv = card->driver;
|
||||||
|
|
||||||
if (priv->base)
|
free (priv->base);
|
||||||
free (priv->base);
|
|
||||||
xfree (priv);
|
xfree (priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,8 +75,7 @@ BusInit (KdPointerInfo *pi)
|
||||||
if ((fd = open (BusNames[i], 0)) >= 0)
|
if ((fd = open (BusNames[i], 0)) >= 0)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
if (pi->path)
|
xfree(pi->path);
|
||||||
xfree(pi->path);
|
|
||||||
pi->path = strdup(BusNames[i]);
|
pi->path = strdup(BusNames[i]);
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
|
@ -737,11 +737,9 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
|
||||||
if (!ki)
|
if (!ki)
|
||||||
return !Success;
|
return !Success;
|
||||||
|
|
||||||
if (ki->path)
|
xfree(ki->path);
|
||||||
xfree(ki->path);
|
|
||||||
ki->path = strdup("console");
|
ki->path = strdup("console");
|
||||||
if (ki->name)
|
xfree(ki->name);
|
||||||
xfree(ki->name);
|
|
||||||
ki->name = strdup("Linux console keyboard");
|
ki->name = strdup("Linux console keyboard");
|
||||||
|
|
||||||
readKernelMapping (ki);
|
readKernelMapping (ki);
|
||||||
|
|
|
@ -175,10 +175,8 @@ TslibInit (KdPointerInfo *pi)
|
||||||
static void
|
static void
|
||||||
TslibFini (KdPointerInfo *pi)
|
TslibFini (KdPointerInfo *pi)
|
||||||
{
|
{
|
||||||
if (pi->driverPrivate) {
|
xfree(pi->driverPrivate);
|
||||||
xfree(pi->driverPrivate);
|
pi->driverPrivate = NULL;
|
||||||
pi->driverPrivate = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -138,40 +138,28 @@ KdFreePointer(KdPointerInfo *pi)
|
||||||
{
|
{
|
||||||
InputOption *option, *prev = NULL;
|
InputOption *option, *prev = NULL;
|
||||||
|
|
||||||
if (pi->name)
|
xfree(pi->name);
|
||||||
xfree(pi->name);
|
xfree(pi->path);
|
||||||
if (pi->path)
|
|
||||||
xfree(pi->path);
|
|
||||||
|
|
||||||
for (option = pi->options; option; option = option->next) {
|
for (option = pi->options; option; option = option->next) {
|
||||||
if (prev)
|
xfree(prev);
|
||||||
xfree(prev);
|
xfree(option->key);
|
||||||
if (option->key)
|
xfree(option->value);
|
||||||
xfree(option->key);
|
|
||||||
if (option->value)
|
|
||||||
xfree(option->value);
|
|
||||||
prev = option;
|
prev = option;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev)
|
xfree(prev);
|
||||||
xfree(prev);
|
|
||||||
|
|
||||||
xfree(pi);
|
xfree(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
KdFreeKeyboard(KdKeyboardInfo *ki)
|
KdFreeKeyboard(KdKeyboardInfo *ki)
|
||||||
{
|
{
|
||||||
if (ki->name)
|
xfree(ki->name);
|
||||||
xfree(ki->name);
|
xfree(ki->path);
|
||||||
if (ki->path)
|
xfree(ki->xkbRules);
|
||||||
xfree(ki->path);
|
xfree(ki->xkbModel);
|
||||||
if (ki->xkbRules)
|
xfree(ki->xkbLayout);
|
||||||
xfree(ki->xkbRules);
|
|
||||||
if (ki->xkbModel)
|
|
||||||
xfree(ki->xkbModel);
|
|
||||||
if (ki->xkbLayout)
|
|
||||||
xfree(ki->xkbLayout);
|
|
||||||
ki->next = NULL;
|
ki->next = NULL;
|
||||||
xfree(ki);
|
xfree(ki);
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,20 +247,18 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(pAdaptor->name)
|
xfree(pAdaptor->name);
|
||||||
xfree(pAdaptor->name);
|
|
||||||
|
|
||||||
if(pAdaptor->pEncodings) {
|
if(pAdaptor->pEncodings) {
|
||||||
XvEncodingPtr pEncode = pAdaptor->pEncodings;
|
XvEncodingPtr pEncode = pAdaptor->pEncodings;
|
||||||
|
|
||||||
for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
|
for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
|
||||||
if(pEncode->name) xfree(pEncode->name);
|
xfree(pEncode->name);
|
||||||
}
|
}
|
||||||
xfree(pAdaptor->pEncodings);
|
xfree(pAdaptor->pEncodings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pAdaptor->pFormats)
|
xfree(pAdaptor->pFormats);
|
||||||
xfree(pAdaptor->pFormats);
|
|
||||||
|
|
||||||
if(pAdaptor->pPorts) {
|
if(pAdaptor->pPorts) {
|
||||||
XvPortPtr pPort = pAdaptor->pPorts;
|
XvPortPtr pPort = pAdaptor->pPorts;
|
||||||
|
@ -283,17 +281,15 @@ KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
|
||||||
XvAttributePtr pAttribute = pAdaptor->pAttributes;
|
XvAttributePtr pAttribute = pAdaptor->pAttributes;
|
||||||
|
|
||||||
for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
|
for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
|
||||||
if(pAttribute->name) xfree(pAttribute->name);
|
xfree(pAttribute->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(pAdaptor->pAttributes);
|
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
|
static Bool
|
||||||
|
@ -1157,12 +1153,9 @@ KdXVCloseScreen(int i, ScreenPtr pScreen)
|
||||||
KdXVFreeAdaptor(pa);
|
KdXVFreeAdaptor(pa);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pxvs->pAdaptors)
|
xfree(pxvs->pAdaptors);
|
||||||
xfree(pxvs->pAdaptors);
|
|
||||||
|
|
||||||
xfree(ScreenPriv);
|
xfree(ScreenPriv);
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue