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

Re: [PATCH] Keywords as Hash 3 - libsvn_client

From: John Peacock <jpeacock_at_rowman.com>
Date: 2005-09-21 21:43:28 CEST

Greg Hudson wrote:
> I think you'd be merely cloaking the problem and preventing the compiler
> from warning you about it, frankly.

In my experience, compilers are often not smart enough to know when to
issue the "not initialized before use" warnings, and sometimes they warn
when you are, in fact, very sure that the variable will be set. Running
something like valgrind finds a lot of these, but the noise from system
libraries often obscures actual misuse. The simple fact that some
compilers always set pointers to NULL (and that gdb does as well when
running) makes it very difficult to track down some of these
uninitialized usage problems.

> Using a variable before it's
> properly set is a bug, whether or not the variable has been set to some
> arbitrary default value beforehand.

It's very much not an arbitrary value if the API specifies that the
pointer can either be NULL or a filled hash. I properly set the
keywords pointer to be NULL and only later conditionally create a hash
and populate it. I'm not suggesting that all apr_hash_t's be assigned
to NULL just to make sure we never dereference random memory; I'm saying
that this API uses NULL as a specific value, which is legitimate way to
use as an initial value globally.

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Boulevard
Suite H
Lanham, MD  20706
301-459-3366 x.5010
fax 301-429-5748
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Sep 21 21:43:51 2005

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