[freetds] too many casts, sire

James K. Lowden jklowden at schemamania.org
Tue Apr 6 23:15:31 EDT 2004


I came across this line in bcp.c (reformatted):

if ((curptr->nextptr = 
	(struct fflist *) malloc(sizeof(struct fflist))) 
		== (struct fflist *) NULL)

ANSI C says:

1.  It's never necessary to cast to compare to a null pointer.  
2.  It's never necessary to cast void* for assignment.  

That tells me this could as well read:

if ((curptr->nextptr = 
	malloc(sizeof(struct fflist))) == NULL)

which I can actually read.  Is there any reason not to simplify this?  Is
anyone really using a malloc() that returns char* in 2004?  (The casting
of NULL is just plain egregious, not merely old fashioned.)


More information about the FreeTDS mailing list