You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Senthil Kumaran S <se...@collab.net> on 2008/06/10 07:34:46 UTC

Re: svn commit: r31622 - trunk/subversion/libsvn_repos

Hi Daniel,

danielsh@tigris.org wrote:
> +      if (capabilities)
> +        {
> +          capabilities_string = svn_cstring_join(capabilities, ":", pool);
> +
> +          /* Get rid of that annoying final colon. */
> +          if (capabilities_string[0])
> +            capabilities_string[strlen(capabilities_string) - 1] = '\0';
> +        }
> +      else
> +        {
> +          capabilities_string = "";
> +        }

We cannot assign a string constant directly like that. A good compiler will 
give the following.

<snip>
../subversion/libsvn_repos/hooks.c: In function 'svn_repos__hooks_start_commit':
../subversion/libsvn_repos/hooks.c:579: warning: assignment discards qualifiers 
from pointer target type
</snip>

My compiler version is:
gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The attached patch fixes this :)

[[[
Fix a compiler warning.

* subversion/libsvn_repos/hooks.c
   (svn_repos__hooks_start_commit): Fix a compiler warning of 'assignment
    discards qualifiers from pointer target type'.

Patch by: stylesen
]]]

Thank You.
-- 
Senthil Kumaran S
http://www.stylesen.org/

Re: svn commit: r31622 - trunk/subversion/libsvn_repos

Posted by Daniel Shahaf <d....@daniel.shahaf.co.il>.
Stefan Sperling wrote on Tue, 10 Jun 2008 at 13:03 +0200:
> On Tue, Jun 10, 2008 at 01:14:22PM +0530, Kamesh Jayachandran wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> > 
> > Senthil,
> > 
> > - -          capabilities_string = "";
> > +          strcpy(capabilities_string, "");
> > 
> > You can not copy to such un-initialized location.
> > 
> > May the fix could be
> > - -          capabilities_string = "";
> > +          capabilities_string = apr_pstrdup(pool, "");
> 
> Heh, that's what I had originally :)
> Somewhere along the way of getting this fix in the strdup()
> was dropped.
> 

My fault, I probably forgot to check for compiler warnings before
I committed.

> Applied in r31673.
> 

Thanks everyone :)

Daniel
<bikeshed>(who thinks pstrdup("") is ugly)</bikeshed>

> Thanks,
> Stefan
> 
> 

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

Re: svn commit: r31622 - trunk/subversion/libsvn_repos

Posted by Stefan Sperling <st...@elego.de>.
On Tue, Jun 10, 2008 at 01:14:22PM +0530, Kamesh Jayachandran wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Senthil,
> 
> - -          capabilities_string = "";
> +          strcpy(capabilities_string, "");
> 
> You can not copy to such un-initialized location.
> 
> May the fix could be
> - -          capabilities_string = "";
> +          capabilities_string = apr_pstrdup(pool, "");

Heh, that's what I had originally :)
Somewhere along the way of getting this fix in the strdup()
was dropped.

Applied in r31673.

Thanks,
Stefan


Re: svn commit: r31622 - trunk/subversion/libsvn_repos

Posted by Senthil Kumaran S <se...@collab.net>.
Kamesh Jayachandran wrote:
> - -          capabilities_string = "";
> +          strcpy(capabilities_string, "");
> 
> You can not copy to such un-initialized location.
> 
> May the fix could be
> - -          capabilities_string = "";
> +          capabilities_string = apr_pstrdup(pool, "");

Yes Kamesh, I am +1 for this.

Thank You.
-- 
Senthil Kumaran S
http://www.stylesen.org/

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

Re: svn commit: r31622 - trunk/subversion/libsvn_repos

Posted by Kamesh Jayachandran <ka...@collab.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Senthil,

- -          capabilities_string = "";
+          strcpy(capabilities_string, "");

You can not copy to such un-initialized location.

May the fix could be
- -          capabilities_string = "";
+          capabilities_string = apr_pstrdup(pool, "");

With regards
Kamesh Jayachandran

Senthil Kumaran S wrote:
> Hi Daniel,
> 
> danielsh@tigris.org wrote:
>> +      if (capabilities)
>> +        {
>> +          capabilities_string = svn_cstring_join(capabilities, ":",
>> pool);
>> +
>> +          /* Get rid of that annoying final colon. */
>> +          if (capabilities_string[0])
>> +            capabilities_string[strlen(capabilities_string) - 1] = '\0';
>> +        }
>> +      else
>> +        {
>> +          capabilities_string = "";
>> +        }
> 
> We cannot assign a string constant directly like that. A good compiler
> will give the following.
> 
> <snip>
> ../subversion/libsvn_repos/hooks.c: In function
> 'svn_repos__hooks_start_commit':
> ../subversion/libsvn_repos/hooks.c:579: warning: assignment discards
> qualifiers from pointer target type
> </snip>
> 
> My compiler version is:
> gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
> Copyright (C) 2006 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> The attached patch fixes this :)
> 
> [[[
> Fix a compiler warning.
> 
> * subversion/libsvn_repos/hooks.c
>   (svn_repos__hooks_start_commit): Fix a compiler warning of 'assignment
>    discards qualifiers from pointer target type'.
> 
> Patch by: stylesen
> ]]]
> 
> Thank You.
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFITjDW3WHvyO0YTCwRAgo4AJ48L3gGui+JTa+pIeG/7Zg7mof4bACggDk9
cwrxDyCn7uJnhye39/tbq5E=
=x0DD
-----END PGP SIGNATURE-----

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