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

Shutting up warnings (was: Re: [wc-propcaching] Use of uninitialized variable (libsvn_wc/props.c))

From: Peter N. Lundblad <peter_at_famlundblad.se>
Date: 2005-11-20 22:52:19 CET

On Sun, 20 Nov 2005, Erik Huelsmann wrote:
> I get a gcc warning about base_props being used uninitialized in
> svn_wc__load_props.

With gcc 4.0.2 I gets a lot of such warnings all over the code. The topic
of shutting up warnings has been up for discussion before and some people
have objected because just setting a value to NULL (or some other bogus
value) might just hide real bugs. Said more as a general comment to
current threads. The below doesn't necessarily do that. Problem is that
different compilers seem to produce this warning in different situations.
In this case, the warning is bogus, AFAICT.

> I propose this patch to fix it:

> Index: subversion/libsvn_wc/props.c
> ===================================================================
> --- subversion/libsvn_wc/props.c (revision 17455)
> +++ subversion/libsvn_wc/props.c (working copy)
> @@ -387,11 +387,14 @@
> if (base_props_p)
> *base_props_p = base_props;
> }
> + else
> + base_props = NULL;
>
> if (props_p)
> {
> if (has_propcaching && ! entry->prop_mods && entry->has_props)
> - *props_p = apr_hash_copy (pool, base_props);
> + *props_p = base_props
> + ? apr_hash_copy (pool, base_props) : apr_hash_make (pool);

If I'm not missing something (which might well be true, since I wrote this
code), base_props can never be NULL here. I think it is confusing to add
code that will never be executed. (An assert is better if that's desired.)

> else if (! has_propcaching || entry->has_props)
> {
> const char *prop_path;

Thanks,
//Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sun Nov 20 22:52:50 2005

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.