bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gnulib] exclude.c change to remove unnecessary casts; generalize?


From: Paul Eggert
Subject: [Bug-gnulib] exclude.c change to remove unnecessary casts; generalize?
Date: Wed, 04 Jun 2003 16:42:27 -0700

I installed the following patch imported from coreutils.  The casts
are no longer needed now that we can assume C89, where malloc,
xmalloc, etc. return void * rather than char *.

This raises the more general issue of whether we should remove these
unnecessary casts from other modules.  I found instances of such casts
in:

bumpalloc.h
canon-host.c
concatpath.c
getgroups.c
getopt.c
getusershell.c
group-member.c
hash.c
localcharset.c
idcache.c
mountlist.c
putenv.c
readtokens.c
readutmp.c
regex.c (does Emacs still require portability to K&R C?)
setenv.c
vasnprintf.c


2003-06-04  Paul Eggert  <address@hidden>

         * exclude.c: (new_exclude, add_exclude): Remove casts that are
         unnecessary now that we assume C89 or better.  This change
         imported from coreutils.

Index: lib/exclude.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/exclude.c,v
retrieving revision 1.14
diff -p -u -r1.14 exclude.c
--- lib/exclude.c       4 Jun 2003 19:22:29 -0000       1.14
+++ lib/exclude.c       4 Jun 2003 23:35:07 -0000
@@ -98,11 +98,10 @@ struct exclude
 struct exclude *
 new_exclude (void)
 {
-  struct exclude *ex = (struct exclude *) xmalloc (sizeof *ex);
+  struct exclude *ex = xmalloc (sizeof *ex);
   ex->exclude_count = 0;
   ex->exclude_alloc = (1 << 6); /* This must be a power of 2.  */
-  ex->exclude = (struct patopts *) xmalloc (ex->exclude_alloc
-                                           * sizeof ex->exclude[0]);
+  ex->exclude = xmalloc (ex->exclude_alloc * sizeof ex->exclude[0]);
   return ex;
 }
 
@@ -200,8 +199,7 @@ add_exclude (struct exclude *ex, char co
       if (! (0 < s && s <= SIZE_MAX / sizeof ex->exclude[0]))
        xalloc_die ();
       ex->exclude_alloc = s;
-      ex->exclude = (struct patopts *) xrealloc (ex->exclude,
-                                                s * sizeof ex->exclude[0]);
+      ex->exclude = xrealloc (ex->exclude, s * sizeof ex->exclude[0]);
     }
 
   patopts = &ex->exclude[ex->exclude_count++];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]