[PATCH:libFS 2/6] Get rid of unnecessary casts in FSfree calls

Alan Coopersmith alan.coopersmith at oracle.com
Fri Apr 12 20:58:43 PDT 2013


No need to cast all other pointers to char *, since C89 free takes
any type of pointer.   Casting all of them just hides errors if you
try to free something that's not really a pointer.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/FSFontInfo.c |   98 +++++++++++++++++++++++++++---------------------------
 src/FSFtNames.c  |    4 +--
 src/FSGetCats.c  |    2 +-
 src/FSListCats.c |    4 +--
 src/FSListExt.c  |    4 +--
 src/FSOpenServ.c |   12 +++----
 src/FSQGlyphs.c  |    8 ++---
 src/FSQXInfo.c   |    2 +-
 8 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/src/FSFontInfo.c b/src/FSFontInfo.c
index fcc91ea..bfeeb65 100644
--- a/src/FSFontInfo.c
+++ b/src/FSFontInfo.c
@@ -102,22 +102,22 @@ FSListFontsWithXInfo(
 	}
 	if (!status) {
 	    for (j = (i - 1); j >= 0; j--) {
-		FSfree((char *) fhdr[j]);
-		FSfree((char *) pi[j]);
-		FSfree((char *) po[j]);
-		FSfree((char *) pd[j]);
+		FSfree(fhdr[j]);
+		FSfree(pi[j]);
+		FSfree(po[j]);
+		FSfree(pd[j]);
 		FSfree(flist[j]);
 	    }
 	    if (flist)
-		FSfree((char *) flist);
+		FSfree(flist);
 	    if (fhdr)
-		FSfree((char *) fhdr);
+		FSfree(fhdr);
 	    if (pi)
-		FSfree((char *) pi);
+		FSfree(pi);
 	    if (po)
-		FSfree((char *) po);
+		FSfree(po);
 	    if (pd)
-		FSfree((char *) pd);
+		FSfree(pd);
 
 	    SyncHandle();
 	    return (char **) NULL;
@@ -147,32 +147,32 @@ FSListFontsWithXInfo(
 
 		if (!tmp_fhdr || !tmp_flist || !tmp_pi || !tmp_po || !tmp_pd) {
 		    for (j = (i - 1); j >= 0; j--) {
-			FSfree((char *) flist[j]);
-			FSfree((char *) fhdr[j]);
-			FSfree((char *) pi[j]);
-			FSfree((char *) po[j]);
-			FSfree((char *) pd[j]);
+			FSfree(flist[j]);
+			FSfree(fhdr[j]);
+			FSfree(pi[j]);
+			FSfree(po[j]);
+			FSfree(pd[j]);
 		    }
 		    if (tmp_flist)
-			FSfree((char *) tmp_flist);
+			FSfree(tmp_flist);
 		    else
-			FSfree((char *) flist);
+			FSfree(flist);
 		    if (tmp_fhdr)
-			FSfree((char *) tmp_fhdr);
+			FSfree(tmp_fhdr);
 		    else
-			FSfree((char *) fhdr);
+			FSfree(fhdr);
 		    if (tmp_pi)
-			FSfree((char *) tmp_pi);
+			FSfree(tmp_pi);
 		    else
-			FSfree((char *) pi);
+			FSfree(pi);
 		    if (tmp_po)
-			FSfree((char *) tmp_po);
+			FSfree(tmp_po);
 		    else
-			FSfree((char *) po);
+			FSfree(po);
 		    if (tmp_pd)
-			FSfree((char *) tmp_pd);
+			FSfree(tmp_pd);
 		    else
-			FSfree((char *) pd);
+			FSfree(pd);
 		    goto clearwire;
 		}
 		fhdr = tmp_fhdr;
@@ -184,25 +184,25 @@ FSListFontsWithXInfo(
 		if (!(fhdr = FSmalloc(sizeof(FSXFontInfoHeader *) * size)))
 		    goto clearwire;
 		if (!(flist = FSmalloc(sizeof(char *) * size))) {
-		    FSfree((char *) fhdr);
+		    FSfree(fhdr);
 		    goto clearwire;
 		}
 		if (!(pi = FSmalloc(sizeof(FSPropInfo *) * size))) {
-		    FSfree((char *) fhdr);
-		    FSfree((char *) flist);
+		    FSfree(fhdr);
+		    FSfree(flist);
 		    goto clearwire;
 		}
 		if (!(po = FSmalloc(sizeof(FSPropOffset *) * size))) {
-		    FSfree((char *) fhdr);
-		    FSfree((char *) flist);
-		    FSfree((char *) pi);
+		    FSfree(fhdr);
+		    FSfree(flist);
+		    FSfree(pi);
 		    goto clearwire;
 		}
 		if (!(pd = FSmalloc(sizeof(unsigned char *) * size))) {
-		    FSfree((char *) fhdr);
-		    FSfree((char *) flist);
-		    FSfree((char *) pi);
-		    FSfree((char *) po);
+		    FSfree(fhdr);
+		    FSfree(flist);
+		    FSfree(pi);
+		    FSfree(po);
 		    goto clearwire;
 		}
 	    }
@@ -229,7 +229,7 @@ FSListFontsWithXInfo(
 
 	pi[i] = FSmalloc(sizeof(FSPropInfo));
 	if (!pi[i]) {
-	    FSfree((char *) fhdr[i]);
+	    FSfree(fhdr[i]);
 	    goto badmem;
 	}
 	_FSReadPad(svr, (char *) &local_pi, SIZEOF(fsPropInfo));
@@ -243,15 +243,15 @@ FSListFontsWithXInfo(
 
 	po[i] = FSmalloc(pi[i]->num_offsets * sizeof(FSPropOffset));
 	if (!po[i]) {
-	    FSfree((char *) fhdr[i]);
-	    FSfree((char *) pi[i]);
+	    FSfree(fhdr[i]);
+	    FSfree(pi[i]);
 	    goto badmem;
 	}
 	pd[i] = FSmalloc(pi[i]->data_len);
 	if (!pd[i]) {
-	    FSfree((char *) fhdr[i]);
-	    FSfree((char *) pi[i]);
-	    FSfree((char *) po[i]);
+	    FSfree(fhdr[i]);
+	    FSfree(pi[i]);
+	    FSfree(po[i]);
 	    goto badmem;
 	}
 	/* get offsets */
@@ -300,22 +300,22 @@ FSListFontsWithXInfo(
 
 badmem:
     for (j = (i - 1); j >= 0; j--) {
-	FSfree((char *) pi[j]);
-	FSfree((char *) po[j]);
-	FSfree((char *) pd[j]);
+	FSfree(pi[j]);
+	FSfree(po[j]);
+	FSfree(pd[j]);
 	FSfree(flist[j]);
-	FSfree((char *) fhdr[j]);
+	FSfree(fhdr[j]);
     }
     if (flist)
-	FSfree((char *) flist);
+	FSfree(flist);
     if (fhdr)
-	FSfree((char *) fhdr);
+	FSfree(fhdr);
     if (pi)
-	FSfree((char *) pi);
+	FSfree(pi);
     if (po)
-	FSfree((char *) po);
+	FSfree(po);
     if (pd)
-	FSfree((char *) pd);
+	FSfree(pd);
 
 
 clearwire:
diff --git a/src/FSFtNames.c b/src/FSFtNames.c
index 470c176..f884d75 100644
--- a/src/FSFtNames.c
+++ b/src/FSFtNames.c
@@ -91,7 +91,7 @@ FSListFonts(
 
 	if ((!flist) || (!c)) {
 	    if (flist)
-		FSfree((char *) flist);
+		FSfree(flist);
 	    if (c)
 		FSfree(c);
 	    _FSEatData(svr, (unsigned long) rlen);
@@ -122,7 +122,7 @@ int FSFreeFontNames(char **list)
 {
     if (list) {
 	FSfree(list[0] - 1);
-	FSfree((char *) list);
+	FSfree(list);
     }
     return 1;
 }
diff --git a/src/FSGetCats.c b/src/FSGetCats.c
index e009add..75f8c36 100644
--- a/src/FSGetCats.c
+++ b/src/FSGetCats.c
@@ -84,7 +84,7 @@ FSGetCatalogues(
 	c = FSmalloc(rlen + 1);
 	if ((!list) || (!c)) {
 	    if (list)
-		FSfree((char *) list);
+		FSfree(list);
 	    if (c)
 		FSfree(c);
 	    _FSEatData(svr, (unsigned long) rlen);
diff --git a/src/FSListCats.c b/src/FSListCats.c
index d27f211..0135792 100644
--- a/src/FSListCats.c
+++ b/src/FSListCats.c
@@ -91,7 +91,7 @@ FSListCatalogues(
 
 	if ((!clist) || (!c)) {
 	    if (clist)
-		FSfree((char *) clist);
+		FSfree(clist);
 	    if (c)
 		FSfree(c);
 	    _FSEatData(svr, (unsigned long) rlen);
@@ -122,7 +122,7 @@ int FSFreeCatalogues(char **list)
 {
     if (list) {
 	FSfree(list[0] - 1);
-	FSfree((char *) list);
+	FSfree(list);
     }
     return 1;
 }
diff --git a/src/FSListExt.c b/src/FSListExt.c
index ca4254e..c127003 100644
--- a/src/FSListExt.c
+++ b/src/FSListExt.c
@@ -84,7 +84,7 @@ FSListExtensions(
 	c = FSmalloc(rlen + 1);
 	if ((!list) || (!c)) {
 	    if (list)
-		FSfree((char *) list);
+		FSfree(list);
 	    if (c)
 		FSfree(c);
 	    _FSEatData(svr, (unsigned long) rlen);
@@ -115,7 +115,7 @@ int FSFreeExtensionList(char **list)
 {
     if (list != NULL) {
 	FSfree(list[0] - 1);
-	FSfree((char *) list);
+	FSfree(list);
     }
     return 1;
 }
diff --git a/src/FSOpenServ.c b/src/FSOpenServ.c
index 06750e9..87d13a9 100644
--- a/src/FSOpenServ.c
+++ b/src/FSOpenServ.c
@@ -80,7 +80,7 @@ void _FSFreeServerStructure(FSServer *svr)
     if (svr->buffer)
 	FSfree(svr->buffer);
 
-    FSfree((char *) svr);
+    FSfree(svr);
 }
 
 static
@@ -182,7 +182,7 @@ FSOpenServer(const char *server)
 	alts[i].name = FSmalloc(altlen + 1);
 	if (!alts[i].name) {
 	    while (--i) {
-		FSfree((char *) alts[i].name);
+		FSfree(alts[i].name);
 	    }
 	    goto fail;
 	}
@@ -190,7 +190,7 @@ FSOpenServer(const char *server)
 	alts[i].name[altlen] = '\0';
 	ad += altlen + ((4 - (altlen + 2)) & 3);
     }
-    FSfree((char *) alt_data);
+    FSfree(alt_data);
     alt_data = NULL;
 
     svr->alternate_servers = alts;
@@ -262,9 +262,9 @@ FSOpenServer(const char *server)
     return (svr);
 
   fail: /* Failure: clean up and return null */
-    FSfree((char *) alts);
-    FSfree((char *) alt_data);
-    FSfree((char *) auth_data);
+    FSfree(alts);
+    FSfree(alt_data);
+    FSfree(auth_data);
     OutOfMemory(svr, setup);
     return (FSServer *) NULL;
 
diff --git a/src/FSQGlyphs.c b/src/FSQGlyphs.c
index 9fbe2f4..9681ef0 100644
--- a/src/FSQGlyphs.c
+++ b/src/FSQGlyphs.c
@@ -98,7 +98,7 @@ FSQueryXBitmaps8(
 #if (SIZE_MAX >> 2) <= UINT_MAX
     /* XXX This thest is incomplete */
     if (reply.length > (SIZE_MAX >> 2)) {
-	FSfree((char *) offs);
+	FSfree(offs);
 	return FSBadAlloc;
     }
 #endif
@@ -107,7 +107,7 @@ FSQueryXBitmaps8(
     gd = FSmalloc(left);
     *glyphdata = gd;
     if (!gd) {
-	FSfree((char *) offs);
+	FSfree(offs);
 	return FSBadAlloc;
     }
     for (i=0; i<reply.num_chars; i++)
@@ -183,7 +183,7 @@ FSQueryXBitmaps16(
 #if (SIZE_MAX >> 2) <= UINT_MAX
     /* XXX - this test is incomplete */
     if (reply.length > (SIZE_MAX>>2)) {
-	FSfree((char *) offs);
+	FSfree(offs);
 	return FSBadAlloc;
     }
 #endif
@@ -192,7 +192,7 @@ FSQueryXBitmaps16(
     gd = FSmalloc(left);
     *glyphdata = gd;
     if (!gd) {
-	FSfree((char *) offs);
+	FSfree(offs);
 	return FSBadAlloc;
     }
     for (i=0; i<reply.num_chars; i++)
diff --git a/src/FSQXInfo.c b/src/FSQXInfo.c
index 3e3a564..0edae0a 100644
--- a/src/FSQXInfo.c
+++ b/src/FSQXInfo.c
@@ -103,7 +103,7 @@ FSQueryXInfo(
 	return FSBadAlloc;
     pdata = FSmalloc(props->data_len);
     if (!pdata) {
-	FSfree((char *) offset_data);
+	FSfree(offset_data);
 	return FSBadAlloc;
     }
     /* get offsets */
-- 
1.7.9.2



More information about the xorg-devel mailing list