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

Re: svn commit: r1103490 - /subversion/trunk/subversion/libsvn_ra_svn/marshal.c

From: Stefan Fuhrmann <eqfox_at_web.de>
Date: Thu, 02 Jun 2011 17:55:18 +0200

On 20.05.2011 12:38, Philip Martin wrote:
> Stefan Fuhrmann<eqfox_at_web.de> writes:
>
>> On 15.05.2011 20:23, Blair Zajac wrote:
>>> On May 15, 2011, at 11:06 AM, stefan2_at_apache.org wrote:
>>>> item->kind = SVN_RA_SVN_STRING;
>>>> - item->u.string = apr_palloc(pool, sizeof(*item->u.string));
>>>> - item->u.string->data = stringbuf->data;
>>>> - item->u.string->len = stringbuf->len;
>>>> + item->u.string = (svn_string_t *)(&stringbuf->data);
>>> Is this cast really necessary? I would rather take a small cost hit in preference to the code being safe.
>> r1124677 still does essentially the same but moves
>> it into a separate function and explains in detail how
>> it works and why it is safe.
> It's still not clear, gcc warns:
>
> ../src/subversion/libsvn_ra_svn/marshal.c: In function ‘read_string’:
> ../src/subversion/libsvn_ra_svn/marshal.c:645: warning: assignment discards qualifiers from pointer target type
>
> Your patch says that you are returning a pointer to const because the
> string must not reallocate, but here you are casting away const. Why is
> that safe?
>
Today's series of patches finally addresses that issue and
introduces the new private svn_stringbuf__morph_into_string()
function that does not have the conversion issues anymore.
And it turned out that we can make good use of this function
in quite a number of places.

-- Stefan^2.
Received on 2011-06-02 17:55:48 CEST

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.