[freetds] too many casts, sire

Thompson, Bill D (London) bill_d_thompson at ml.com
Tue Apr 13 09:04:05 EDT 2004


Jim,

I recognise my own code when I see it!
I taught myself C on an IBM RT PC 6150 (anyone else remember those ?) some
17 years ago. 
Maybe on that first version of AIX, it was necessary to cast like that. 
I'll endeavour to bring myself into the 21st century though...perhaps one
day I'll even learn C++ ....

Bill

> -----Original Message-----
> From:	James K. Lowden [SMTP:jklowden at schemamania.org]
> Sent:	07 April 2004 04:16
> To:	TDS Development Group
> Subject:	[freetds] too many casts, sire
> 
> http://www.fiendish.demon.co.uk/c/casting.html
> http://www.vmunix.com/~gabor/c/draft.html#6.2.2.3
> 
> 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.)
> 
> --jkl
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

==============================================================================

If you are not an intended recipient of this e-mail, please notify
the sender, delete it and do not read, act upon, print, disclose,
copy, retain or redistribute it.

Click here for important additional terms relating to this e-mail.
     <http://www.ml.com/email_terms/>

==============================================================================




More information about the FreeTDS mailing list