You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Shahaf <d....@daniel.shahaf.name> on 2010/11/09 22:31:11 UTC

svn_tristate_t Re: svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

stefan2@apache.org wrote on Tue, Nov 09, 2010 at 15:07:48 -0000:
>  /** Generic three-state property to represent an unknown value for values
>   * that are just like booleans.  The values have been set deliberately to
> - * make tristates mainly compatible with #svn_boolean_t.
> + * make tristates disjoint from #svn_boolean_t.
>   *
>   * @since New in 1.7. */
>  typedef enum
>  {
> -  svn_tristate_false = FALSE,
> -  svn_tristate_true = TRUE,
> +  svn_tristate_false = 2,
> +  svn_tristate_true,
>    svn_tristate_unknown
>  } svn_tristate_t;

I see us someday pcalloc()'ing one of these and forgetting to reset it
to the 'svn_tristate_unknown' value.

Could we make compilers catch that for us?

Or should we just assert that the value really is one of those three
values?  Or even interpret any value (except svn_tristate_true and
svn_tristate_false) as "unknown"?

RE: svn_tristate_t Re: svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Daniel Shahaf [mailto:d.s@daniel.shahaf.name]
> Sent: woensdag 10 november 2010 0:26
> To: dev@subversion.apache.org
> Cc: Daniel Shahaf
> Subject: Re: svn_tristate_t Re: svn commit: r1033006 -
> /subversion/trunk/subversion/include/svn_types.h
> 
> Daniel Shahaf wrote on Wed, Nov 10, 2010 at 00:31:11 +0200:
> > I see us someday pcalloc()'ing one of these and forgetting to reset
> it
> > to the 'svn_tristate_unknown' value.
> 
> Actually, svn_log_changed_path2_create() does exactly this.  Right now.

When I introduced svn_tristate_t, 0 was the unknown value...
(And this might have been the reason to do that... but I don't remember the
exact reasoning any more)

	Bert

Re: svn_tristate_t Re: svn commit: r1033006 - /subversion/trunk/subversion/include/svn_types.h

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Daniel Shahaf wrote on Wed, Nov 10, 2010 at 00:31:11 +0200:
> I see us someday pcalloc()'ing one of these and forgetting to reset it
> to the 'svn_tristate_unknown' value.

Actually, svn_log_changed_path2_create() does exactly this.  Right now.