summaryrefslogtreecommitdiff
path: root/hw/kdrive
diff options
context:
space:
mode:
authorMikhail Gusarov <dottedmag@dottedmag.net>2010-01-02 05:43:26 +0600
committerKeith Packard <keithp@keithp.com>2010-01-01 23:27:53 -0800
commit2c85d72fc7bd013af327321ad5d626dc73c3caf0 (patch)
tree4b702217f44a81bd00abd7d3ef39d6f79d477093 /hw/kdrive
parent15bc35c6e44c65812de5c3e85ec8bbf78b032ded (diff)
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>
Diffstat (limited to 'hw/kdrive')
-rw-r--r--hw/kdrive/ephyr/ephyr.c6
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.c21
-rw-r--r--hw/kdrive/ephyr/ephyrglxext.c28
-rw-r--r--hw/kdrive/ephyr/ephyrhostvideo.c6
-rw-r--r--hw/kdrive/ephyr/ephyrvideo.c19
-rw-r--r--hw/kdrive/fake/fake.c5
-rw-r--r--hw/kdrive/linux/bus.c3
-rw-r--r--hw/kdrive/linux/keyboard.c6
-rw-r--r--hw/kdrive/linux/tslib.c6
-rw-r--r--hw/kdrive/src/kinfo.c34
-rw-r--r--hw/kdrive/src/kxv.c21
11 files changed, 57 insertions, 98 deletions
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 254fcbc54..b6a2adaff 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -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;
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index f741d7420..5f5fd3bff 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -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);
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
index 63c4ceda4..a0278cc2b 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -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 ;
}
diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c
index 41c0b755b..f4a1b9d17 100644
--- a/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -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) ;
}
diff --git a/hw/kdrive/ephyr/ephyrvideo.c b/hw/kdrive/ephyr/ephyrvideo.c
index 5058ebe03..bb2ee1032 100644
--- a/hw/kdrive/ephyr/ephyrvideo.c
+++ b/hw/kdrive/ephyr/ephyrvideo.c
@@ -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 ;
}
diff --git a/hw/kdrive/fake/fake.c b/hw/kdrive/fake/fake.c
index ff597981d..ea88f0edb 100644
--- a/hw/kdrive/fake/fake.c
+++ b/hw/kdrive/fake/fake.c
@@ -457,9 +457,8 @@ void
fakeCardFini (KdCardInfo *card)
{
FakePriv *priv = card->driver;
-
- if (priv->base)
- free (priv->base);
+
+ free (priv->base);
xfree (priv);
}
diff --git a/hw/kdrive/linux/bus.c b/hw/kdrive/linux/bus.c
index 93c3ea5f3..de9b90f5a 100644
--- a/hw/kdrive/linux/bus.c
+++ b/hw/kdrive/linux/bus.c
@@ -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;
}
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index 53d3c3a66..6eed7aed3 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -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);
diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index a0b989d3a..322ccc7d5 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -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;
}
diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c
index af6415690..95afc7963 100644
--- a/hw/kdrive/src/kinfo.c
+++ b/hw/kdrive/src/kinfo.c
@@ -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);
}
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 1ceb8c6d3..27ecc5d6c 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -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;
}