[Mesa-dev] [PATCH 3/9] Don't cast the return value of malloc/realloc

Brian Paul brianp at vmware.com
Wed Sep 5 07:30:33 PDT 2012


On 09/05/2012 12:42 AM, Matt Turner wrote:
> This patch has been generated by the following Coccinelle semantic
> patch:
>
> // Don't cast the return value of malloc/realloc.
> //
> // Casting the return value of malloc/realloc only stands to hide
> // errors.

So assigning a void pointer to a non-void pointer is legal in C and 
illegal in C++.  I seem to recall some people compiling all of Mesa 
with C++ in some situations in the past.  Also, there were some C 
compiler(s) years ago that required these casts (can't remember which).

I'm kind of on the fence about this change.

-Brian


More information about the mesa-dev mailing list