Removing casts from code

Ulrich Drepper drepper@redhat.com
Tue Jan 7 02:07:00 GMT 2003


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 `---------------------------



More information about the Libc-alpha mailing list