This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Removing casts from code
- From: Ulrich Drepper <drepper at redhat dot com>
- To: Art Haas <ahaas at airmail dot net>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Mon, 06 Jan 2003 18:07:05 -0800
- Subject: Re: Removing casts from code
- Organization: Red Hat, Inc.
- References: <20030107015334.GB23452@pcdebian.artsapartment.org>
Art Haas wrote:
>
>
> - result = (__nl_catd) malloc (sizeof (*result));
> + result = malloc (sizeof (*result));
> if (result == NULL)
These changes are completely out of question. I want to have return
values of allocation functions casted to the correct type. Some code
you might want some day use with a C++ compiler and it also happened
several times that I changed malloc to alloca() in which can the cast is
sometimes needed.
> /* Couldn't open the file. */
> - free ((void *) result);
> + free (result);
> return (nl_catd) -1;
In this case it is not obvious that the cast isn't necessary. Somebody
might come some day and change nl_catd to long or so.
--
--------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------