Skip to Content.
Sympa Menu

freetds - [freetds] too many casts, sire

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: TDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] too many casts, sire
  • Date: Tue, 6 Apr 2004 23:15:31 -0400

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




Archive powered by MHonArc 2.6.24.

Top of Page