You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Edmund Wong <ed...@kdtc.net> on 2009/11/04 16:39:29 UTC

[PATCH] Remove 'svnver' array warning in svndiff.c when

Hi,

During a Windows compile under VS2008, the following warning is shown:

..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295: 'svnver' :
array is too small to include a terminating null character

Log:

[[[

This patch fixes this misleading assignment.  As per notes/svndiff (thanks
danielsh), svnver = 'SVN\0' where \0 is the format #.  The compiler doesn't
know that and thinks the code is trying to insert another NULL.

* subversion\libsvn_delta\svndiff.c
  window_handler: Changed "SVN\0" to {'S','V','N',0}.

Patch by: Edmund Wong <ed{_AT_}kdtc.net>
Suggested by: rhuijben

]]]



--
KDTC

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414451

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Gavin Baumanis <ga...@thespidernet.com>.
Thanks Julian.


On 11/11/2009, at 11:43 , Julian Foad wrote:

> Gavin Baumanis wrote:
>> Please note that Edmund's revised patch for this is @;
>> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414562
> 
> I have now committed this in r40447. I tweaked it to use '\0' instead of
> 0 to be sure of not getting any "shortening the integer to 8 bits" or
> signed/unsigned type mismatch kind of warnings.
> 
> - Julian
> 
> 
>> On 05/11/2009, at 04:09 , Philip Martin wrote:
>>> Edmund Wong <ed...@kdtc.net> writes:
>>> 
>>>> During a Windows compile under VS2008, the following warning is
>>>> shown:
>>>> 
>>>> ..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295:
>>>> 'svnver' : array is too small to include a terminating null
>>>> character
> 
>>>> -      char svnver[4] = "SVN\0";
>>>> +      char svnver[4] = {'S','V','N',0};
> 
>>> The old code is valid C as I think you know.  It's a slightly
>>> obscure
>>> corner of the language; perhaps we should use {'S', 'V', 'N', '-'}
>>> to
>>> indicate that it is not a null terminated string.
> 
> 
>

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416344

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Roman Donchenko <DX...@yandex.ru>.
Julian Foad <ju...@btopenworld.com> писал(а) в своём письме Wed, 11
Nov 2009 03:43:19 +0300:

> Gavin Baumanis wrote:
>> Please note that Edmund's revised patch for this is @;
>> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414562
>
> I have now committed this in r40447. I tweaked it to use '\0' instead of
> 0 to be sure of not getting any "shortening the integer to 8 bits" or
> signed/unsigned type mismatch kind of warnings.
>
> - Julian

FWIW, both 0 and '\0' are of type int (and you could've just omitted this
element entirely 8=]).

Roman.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416767

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Julian Foad <ju...@btopenworld.com>.
Gavin Baumanis wrote:
> Please note that Edmund's revised patch for this is @;
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414562

I have now committed this in r40447. I tweaked it to use '\0' instead of
0 to be sure of not getting any "shortening the integer to 8 bits" or
signed/unsigned type mismatch kind of warnings.

- Julian


> On 05/11/2009, at 04:09 , Philip Martin wrote:
> > Edmund Wong <ed...@kdtc.net> writes:
> > 
> > > During a Windows compile under VS2008, the following warning is
> > > shown:
> > > 
> > > ..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295:
> > > 'svnver' : array is too small to include a terminating null
> > > character

> > > -      char svnver[4] = "SVN\0";
> > > +      char svnver[4] = {'S','V','N',0};

> > The old code is valid C as I think you know.  It's a slightly
> > obscure
> > corner of the language; perhaps we should use {'S', 'V', 'N', '-'}
> > to
> > indicate that it is not a null terminated string.

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416325

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Edmund Wong <ed...@kdtc.net>.
Gavin Baumanis wrote:
> Please note that Edmund's revised patch for this is @;
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414562
> 
> (Which has also received no comments.)
> 

Thanks Gavin!  Very much appreciate the help with the pinging
on the patch.

Edmund

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416368

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Gavin Baumanis <ga...@thespidernet.com>.
Please note that Edmund's revised patch for this is @;
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414562

(Which has also received no comments.)


Gavin.

On 05/11/2009, at 04:09 , Philip Martin wrote:

> Edmund Wong <ed...@kdtc.net> writes:
>
>> During a Windows compile under VS2008, the following warning is  
>> shown:
>>
>> ..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295:  
>> 'svnver' :
>> array is too small to include a terminating null character
>
>> Index: subversion/libsvn_delta/svndiff.c
>> ===================================================================
>> --- subversion/libsvn_delta/svndiff.c	(revision 40372)
>> +++ subversion/libsvn_delta/svndiff.c	(working copy)
>> @@ -190,7 +190,7 @@
>>   /* Make sure we write the header.  */
>>   if (eb->header_done == FALSE)
>>     {
>> -      char svnver[4] = "SVN\0";
>> +      char svnver[4] = {'S','V','N',0};
>>       len = 4;
>>       svnver[3] = eb->version;
>>       SVN_ERR(svn_stream_write(eb->output, svnver, &len));
>
> The old code is valid C as I think you know.  It's a slightly obscure
> corner of the language; perhaps we should use {'S', 'V', 'N', '-'} to
> indicate that it is not a null terminated string.
>
> -- 
> Philip
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414466

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416309

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Gavin Baumanis <ga...@thespidernet.com>.
Ping. This Submission has received new comments.

Gavin.


On 05/11/2009, at 04:09 , Philip Martin wrote:

> Edmund Wong <ed...@kdtc.net> writes:
>
>> During a Windows compile under VS2008, the following warning is  
>> shown:
>>
>> ..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295:  
>> 'svnver' :
>> array is too small to include a terminating null character
>
>> Index: subversion/libsvn_delta/svndiff.c
>> ===================================================================
>> --- subversion/libsvn_delta/svndiff.c	(revision 40372)
>> +++ subversion/libsvn_delta/svndiff.c	(working copy)
>> @@ -190,7 +190,7 @@
>>   /* Make sure we write the header.  */
>>   if (eb->header_done == FALSE)
>>     {
>> -      char svnver[4] = "SVN\0";
>> +      char svnver[4] = {'S','V','N',0};
>>       len = 4;
>>       svnver[3] = eb->version;
>>       SVN_ERR(svn_stream_write(eb->output, svnver, &len));
>
> The old code is valid C as I think you know.  It's a slightly obscure
> corner of the language; perhaps we should use {'S', 'V', 'N', '-'} to
> indicate that it is not a null terminated string.
>
> -- 
> Philip
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414466

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2416307

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Philip Martin <ph...@wandisco.com>.
Edmund Wong <ed...@kdtc.net> writes:

> During a Windows compile under VS2008, the following warning is shown:
>
> ..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295: 'svnver' :
> array is too small to include a terminating null character

> Index: subversion/libsvn_delta/svndiff.c
> ===================================================================
> --- subversion/libsvn_delta/svndiff.c	(revision 40372)
> +++ subversion/libsvn_delta/svndiff.c	(working copy)
> @@ -190,7 +190,7 @@
>    /* Make sure we write the header.  */
>    if (eb->header_done == FALSE)
>      {
> -      char svnver[4] = "SVN\0";
> +      char svnver[4] = {'S','V','N',0};
>        len = 4;
>        svnver[3] = eb->version;
>        SVN_ERR(svn_stream_write(eb->output, svnver, &len));

The old code is valid C as I think you know.  It's a slightly obscure
corner of the language; perhaps we should use {'S', 'V', 'N', '-'} to
indicate that it is not a null terminated string.

-- 
Philip

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414466

Re: [PATCH] Remove 'svnver' array warning in svndiff.c when

Posted by Branko Cibej <br...@xbc.nu>.
Edmund Wong wrote:
> Hi,
>
> During a Windows compile under VS2008, the following warning is shown:
>
> ..\..\..\subversion\libsvn_delta\svndiff.c(193): warning C4295: 'svnver' :
> array is too small to include a terminating null character
>
> Log:
>
> [[[
>
> This patch fixes this misleading assignment.  As per notes/svndiff (thanks
> danielsh), svnver = 'SVN\0' where \0 is the format #.  The compiler doesn't
> know that and thinks the code is trying to insert another NULL.
>
> * subversion\libsvn_delta\svndiff.c
>   window_handler: Changed "SVN\0" to {'S','V','N',0}.
>
> Patch by: Edmund Wong <ed{_AT_}kdtc.net>
> Suggested by: rhuijben
>   

Hmmm ... That shouldn't be a warning, but on the other hand, using
{"SVN\0"} is just as correct, and easier to read.

Also please use forward slashes for path separators in the log message.

--  Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2414469