This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Removing casts from code


Hi.

This patch is a test-the-waters patch from me. In many places in the
code, the pointer returned from malloc() and friends is cast. In many
other bits of code, there is no cast. As the cast can hide a potential
bug of not including the needed header file, and the removal of the cast
makes the code a teeny-tiny bit smaller, I'm wondering if a set of
cast-removal patches like the one here would be considered worthwhile by
the main developers. If so, I'll start sending a few in. If not, then
trash this patch and I'll look for other smaller or "janitorial" type
fixes I can work on.

2003-01-06  Art Haas  <ahaas@airmail.net>

	* catgets/catgets.c: Remove casts from malloc()/free() calls.

Index: catgets/catgets.c
===================================================================
RCS file: /cvs/glibc/libc/catgets/catgets.c,v
retrieving revision 1.21
diff -u -r1.21 catgets.c
--- catgets/catgets.c	15 May 2002 03:46:42 -0000	1.21
+++ catgets/catgets.c	4 Jan 2003 00:16:44 -0000
@@ -64,7 +64,7 @@
 	nlspath = NLSPATH;
     }
 
-  result = (__nl_catd) malloc (sizeof (*result));
+  result = malloc (sizeof (*result));
   if (result == NULL)
     /* We cannot get enough memory.  */
     return (nl_catd) -1;
@@ -72,7 +72,7 @@
   if (__open_catalog (cat_name, nlspath, env_var, result) != 0)
     {
       /* Couldn't open the file.  */
-      free ((void *) result);
+      free (result);
       return (nl_catd) -1;
     }
 
-- 
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]