You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Max Okumoto <ok...@ucsd.edu> on 2001/12/05 10:19:38 UTC

static const int variable needs init value

 
* subversion/subversion/libsvn_ra_dav/commit.c 
  static const int variable needs init value even if it is zero.

Index: subversion/subversion/libsvn_ra_dav/commit.c
===================================================================
--- subversion/subversion/libsvn_ra_dav/.svn/text-base/commit.c.svn-base	Sun Dec  2 13:34:52 2001
+++ subversion/subversion/libsvn_ra_dav/commit.c	Tue Dec  4 10:28:58 2001
@@ -121,7 +121,7 @@
 ** properties which must be deleted. Properties which are changed/added
 ** will use their new values.
 */
-static const int singleton_delete_prop;
+static const int singleton_delete_prop = 0;
 #define DELETE_THIS_PROP (&singleton_delete_prop)
 
 /* this property will be fetched from the server when we don't find it

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: static const int variable needs init value

Posted by Greg Stein <gs...@lyra.org>.
On Wed, Dec 05, 2001 at 12:48:56PM -0500, Greg Hudson wrote:
>...
> (Stylistically, I would favor an explicit "= 0" in most cases where
> you'd use a "static const int" declaration.  In this case, though, I
> would actually favor getting rid of the "const", if I couldn't find a
> good way to do without the variable entirely.  commit.c is doing
> something really odd with singleton_delete_prop, such that nothing cares
> about its value.  Asserting that the value is constant has no particular
> meaning.)

singleton_delete_prop needs to stick around, even if it looks like it isn't
in use now. I was going to use it to record deleted properties in a prop
values hash. However, when I was away in July, Joe added a second hash table
and put deleted props in there. I preferred a single "prop changes" table.

The singleton [hash value] DELETE_THIS_PROP is used to identify the deleted
props.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: static const int variable needs init value

Posted by Greg Hudson <gh...@mit.edu>.
On Wed, 2001-12-05 at 11:22, Matt Kraai wrote:
> On Wed, Dec 05, 2001 at 02:19:38AM -0800, Max Okumoto wrote:
> > * subversion/subversion/libsvn_ra_dav/commit.c 
> >   static const int variable needs init value even if it is zero.
> 
> Why?  Aren't non-automatic variables zeroed by default?

They are.  A compiler warning about "static const int foo;" is full of
it.  And the native Solaris cc doesn't give me any warning:

small-gods% cat foo.c
static const int blah;
small-gods% cc -V -c foo.c
cc: Sun WorkShop 6 update 1 C 5.2 2000/09/11
acomp: Sun WorkShop 6 update 1 C 5.2 2000/09/11
small-gods% 

So, I'm not sure what Max is seeing.

(Stylistically, I would favor an explicit "= 0" in most cases where
you'd use a "static const int" declaration.  In this case, though, I
would actually favor getting rid of the "const", if I couldn't find a
good way to do without the variable entirely.  commit.c is doing
something really odd with singleton_delete_prop, such that nothing cares
about its value.  Asserting that the value is constant has no particular
meaning.)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: static const int variable needs init value

Posted by Max Okumoto <ok...@ucsd.edu>.
I am currently just fixing the warnings generated
by the solaris compiler, as a way to get familiar
with the code.  So I think that its value is zero
and will always be zero since its const, but the
compiler complained so I fixed it. :-)

			Max Okumoto


Matt Kraai <kr...@alumni.carnegiemellon.edu> writes:

> On Wed, Dec 05, 2001 at 02:19:38AM -0800, Max Okumoto wrote:
> > * subversion/subversion/libsvn_ra_dav/commit.c 
> >   static const int variable needs init value even if it is zero.
> 
> Why?  Aren't non-automatic variables zeroed by default?
> 
> Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: static const int variable needs init value

Posted by Matt Kraai <kr...@alumni.carnegiemellon.edu>.
On Wed, Dec 05, 2001 at 02:19:38AM -0800, Max Okumoto wrote:
> * subversion/subversion/libsvn_ra_dav/commit.c 
>   static const int variable needs init value even if it is zero.

Why?  Aren't non-automatic variables zeroed by default?

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: static const int variable needs init value

Posted by Garance A Drosihn <dr...@rpi.edu>.
At 2:19 AM -0800 12/5/01, Max Okumoto wrote:
>
>* subversion/subversion/libsvn_ra_dav/commit.c
>   static const int variable needs init value even if it is zero.
>

I am pretty sure that the C standard requires that any such
variables will automatically default to zero, if no other
value is specified.  Are you running into a problem where
that variable is not coming up as zero on some platform?

-- 
Garance Alistair Drosehn            =   gad@eclipse.acs.rpi.edu
Senior Systems Programmer           or  gad@freebsd.org
Rensselaer Polytechnic Institute    or  drosih@rpi.edu

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org