[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] fix for issue #591

From: Greg Hudson <ghudson_at_MIT.EDU>
Date: 2002-01-20 22:45:53 CET

On Sun, 2002-01-20 at 15:27, Garrett Rooney wrote:
> On Sun, Jan 20, 2002 at 07:23:25PM +0000, Philip Martin wrote:
> > Garrett Rooney <rooneg@electricjellyfish.net> writes:
> >
> > > > > + apr_hash_this(hi, (const void **)&key, NULL, (void **)&val);

Code like this is not strictly correct C. "key" is a char *, and its
address is a char **. If you cast this to void **, dereference it, and
assign to that, you're assigning a void * value to a char * slot without
a cast conversion.

Of course, on almost all platforms, void * is bit-identical to all the
pointer types it is compatible with, and cast conversions between
pointer types do nothing. But if you care about strictly conforming to
the standards (which, admittedly, most Subversion developers don't),
you'll avoid this kind of looseness.

So, it is cleaner to declare key as void * and cast it to char * (or
assign its value to a char * variable) when you need to use it as such,
but some might find it best to simply minimize the number of casts
regardless of cleanliness.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:57 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.