[PATCH:xdm 2/5] Stop checking for NULL before calling free()

2011-05-14 Thread Alan Coopersmith
Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com
---
 chooser/chooser.c |3 +--
 xdm/access.c  |   15 +--
 xdm/auth.c|9 +++--
 xdm/dm.c  |3 +--
 xdm/dpylist.c |   50 --
 xdm/krb5auth.c|3 +--
 xdm/server.c  |3 +--
 xdm/socket.c  |3 +--
 xdm/util.c|3 +--
 xdm/xdmauth.c |6 ++
 xdm/xdmcp.c   |4 ++--
 11 files changed, 42 insertions(+), 60 deletions(-)

diff --git a/chooser/chooser.c b/chooser/chooser.c
index d3d08ea..01201b7 100644
--- a/chooser/chooser.c
+++ b/chooser/chooser.c
@@ -312,8 +312,7 @@ RebuildTable (int size)
qsort (newTable, size, sizeof (char *), HostnameCompare);
 }
 XawListChange (list, newTable, size, 0, TRUE);
-if (NameTable)
-   free ((char *) NameTable);
+free ((char *) NameTable);
 NameTable = newTable;
 NameTableSize = size;
 }
diff --git a/xdm/access.c b/xdm/access.c
index eae5286..ceace37 100644
--- a/xdm/access.c
+++ b/xdm/access.c
@@ -784,8 +784,7 @@ int ForEachMatchingIndirectHost (
}
break;
 }
-if (clientName)
-   free (clientName);
+free (clientName);
 return haveLocalhost;
 }
 
@@ -823,14 +822,12 @@ int UseChooser (
if (d-notAllowed)
break;
if (d-chooser  !IndirectChoice (clientAddress, connectionType)) {
-   if (clientName)
-   free (clientName);
+   free (clientName);
return 1;
}
break;
 }
-if (clientName)
-   free (clientName);
+free (clientName);
 return 0;
 }
 
@@ -879,8 +876,7 @@ void ForEachChooserHost (
}
break;
 }
-if (clientName)
-   free (clientName);
+free (clientName);
 if (haveLocalhost)
(*function) (connectionType, getLocalAddress(), closure);
 }
@@ -928,8 +924,7 @@ int AcceptableDisplayAddress (
}
break;
 }
-if (clientName)
-   free (clientName);
+free (clientName);
 return (d != 0)  (d-notAllowed == 0)
 (type == BROADCAST_QUERY ? d-notBroadcast == 0 : 1);
 }
diff --git a/xdm/auth.c b/xdm/auth.c
index 63cd15e..ec3a1cc 100644
--- a/xdm/auth.c
+++ b/xdm/auth.c
@@ -505,8 +505,7 @@ SetLocalAuthorization (struct display *d)
 for (i = 0; d-authNames[i]; i++)
;
 d-authNameNum = i;
-if (d-authNameLens)
-   free ((char *) d-authNameLens);
+free ((char *) d-authNameLens);
 d-authNameLens = (unsigned short *) malloc
(d-authNameNum * sizeof (unsigned short));
 if (!d-authNameLens)
@@ -663,10 +662,8 @@ doneAddrs (void)
struct addrList *a, *n;
for (a = addrs; a; a = n) {
n = a-next;
-   if (a-address)
-   free (a-address);
-   if (a-number)
-   free (a-number);
+   free (a-address);
+   free (a-number);
free ((char *) a);
}
 }
diff --git a/xdm/dm.c b/xdm/dm.c
index 9d0f0e8..cd0ee25 100644
--- a/xdm/dm.c
+++ b/xdm/dm.c
@@ -733,8 +733,7 @@ SetWindowPath(struct display *d)
} else {
asprintf(newwindowpath, %s:%lu, windowpath, num);
}
-   if (d-windowPath)
-   free(d-windowPath);
+   free(d-windowPath);
d-windowPath = newwindowpath;
 }
 
diff --git a/xdm/dpylist.c b/xdm/dpylist.c
index dccd679..148f524 100644
--- a/xdm/dpylist.c
+++ b/xdm/dpylist.c
@@ -118,8 +118,6 @@ FindDisplayByAddress (XdmcpNetaddr addr, int addrlen, 
CARD16 displayNumber)
 
 #endif /* XDMCP */
 
-#define IfFree(x)  if (x) free ((char *) x)
-
 void
 RemoveDisplay (struct display *old)
 {
@@ -134,43 +132,43 @@ RemoveDisplay (struct display *old)
p-next = d-next;
else
displays = d-next;
-   IfFree (d-name);
-   IfFree (d-class);
+   free (d-name);
+   free (d-class);
for (x = d-argv; x  *x; x++)
-   IfFree (*x);
-   IfFree (d-argv);
-   IfFree (d-resources);
-   IfFree (d-xrdb);
-   IfFree (d-setup);
-   IfFree (d-startup);
-   IfFree (d-reset);
-   IfFree (d-session);
-   IfFree (d-userPath);
-   IfFree (d-systemPath);
-   IfFree (d-systemShell);
-   IfFree (d-failsafeClient);
-   IfFree (d-chooser);
+   free (*x);
+   free (d-argv);
+   free (d-resources);
+   free (d-xrdb);
+   free (d-setup);
+   free (d-startup);
+   free (d-reset);
+   free (d-session);
+   free (d-userPath);
+   free (d-systemPath);
+   free (d-systemShell);
+   free (d-failsafeClient);
+   free (d-chooser);
if (d-authorizations)
{
for (i = 0; i  d-authNum; i++)
XauDisposeAuth 

Re: [PATCH:xdm 2/5] Stop checking for NULL before calling free()

2011-05-14 Thread Mark Kettenis
 From: Alan Coopersmith alan.coopersm...@oracle.com
 Date: Sat, 14 May 2011 11:01:30 -0700
 
 Signed-off-by: Alan Coopersmith alan.coopersm...@oracle.com

Reviewed-by: Mark Kettenis kette...@openbsd.org

 ---
  chooser/chooser.c |3 +--
  xdm/access.c  |   15 +--
  xdm/auth.c|9 +++--
  xdm/dm.c  |3 +--
  xdm/dpylist.c |   50 --
  xdm/krb5auth.c|3 +--
  xdm/server.c  |3 +--
  xdm/socket.c  |3 +--
  xdm/util.c|3 +--
  xdm/xdmauth.c |6 ++
  xdm/xdmcp.c   |4 ++--
  11 files changed, 42 insertions(+), 60 deletions(-)
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel