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

Re: [PATCH] Remove warning about code not beeing executed

From: Branko Cibej <brane_at_xbc.nu>
Date: Thu, 05 Nov 2009 22:25:19 +0100

Stefan Sperling wrote:
> On Thu, Nov 05, 2009 at 07:28:18PM +0100, Daniel Näslund wrote:
>
>> [[[
>> Fix warning of code never beeing executed.
>>
>> * subversion/libsvn_client/deprecated.c
>> (wrap_pre_blame3_receiver): Add eol parameter to avoid check of
>> strlen() against APR_EOL_STR.
>> (svn_client_blame2, svn_client_blame): Update caller to pass
>> APR_EOL_STR as eol.
>>
>> Patch by: Daniel Näslund <daniel_at_longitudo.com>
>> ]]]
>>
>> /Daniel
>>
>
>
>> Index: subversion/libsvn_client/deprecated.c
>> ===================================================================
>> --- subversion/libsvn_client/deprecated.c (revision 40386)
>> +++ subversion/libsvn_client/deprecated.c (arbetskopia)
>> @@ -284,10 +284,10 @@
>>
>> static void
>> wrap_pre_blame3_receiver(svn_client_blame_receiver_t *receiver,
>> - void **receiver_baton,
>> + void **receiver_baton, const char *eol,
>> apr_pool_t *pool)
>> {
>> - if (strlen(APR_EOL_STR) > 1)
>> + if (strlen(eol) > 1)
>>
>
> No idea if we really need to fix this.
>

I think the result is way too convoluted to be considered a "fix".

> There's a nice snippet in libsvn_subr/prompt.c which generates a similar
> warning but avoids strlen():
>
> /* GCC might complain here: "warning: will never be executed"
> * That's fine. This is a compile-time check for "\r\n\0" */
> if (sizeof(APR_EOL_STR) == 3)
> {
> saw_first_half_of_eol = TRUE;
> continue;
> }
>

Yup. I'd recommend avoiding the strlen, but that's all. And *carefully*
because there'a an off-by-one just waiting to happen when you replace
strlen with sizeof. :)

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414923
Received on 2009-11-05 22:25:32 CET

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.