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]

Re: Removing casts from code


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


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