You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2011/05/09 18:28:16 UTC

svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Author: stefan2
Date: Mon May  9 16:28:16 2011
New Revision: 1101091

URL: http://svn.apache.org/viewvc?rev=1101091&view=rev
Log:
Fix a number of conversion and formatting issues.

* subversion/libsvn_subr/cache-membuffer.c
  (MIN_SEGMENT_SIZE): ensure that cache sizes > 4GB work
  (svn_cache__membuffer_cache_create): formatting fixes; add missing cast

Modified:
    subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Modified: subversion/trunk/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache-membuffer.c?rev=1101091&r1=1101090&r2=1101091&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache-membuffer.c Mon May  9 16:28:16 2011
@@ -115,7 +115,7 @@
 /* Don't create cache segments smaller than this value unless the total
  * cache size itself is smaller.
  */
-#define MIN_SEGMENT_SIZE 0x2000000
+#define MIN_SEGMENT_SIZE 0x2000000ull
 
 /* Invalid index reference value. Equivalent to APR_UINT32_T(-1)
  */
@@ -925,13 +925,13 @@ svn_cache__membuffer_cache_create(svn_me
    * Segments should not be smaller than 32MB and max. cachable item
    * size should grow as fast as segmentation.
    */
-  while ((2 * MIN_SEGMENT_SIZE << (2 * segment_count_shift)) < total_size)
+  while (((2 * MIN_SEGMENT_SIZE) << (2 * segment_count_shift)) < total_size)
     ++segment_count_shift;
 
   segment_count = 1 << segment_count_shift;
 
   /* allocate cache as an array of segments / cache objects */
-  c = apr_palloc(pool, segment_count * sizeof(*c));
+  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));
 
   /* Split total cache size into segments of equal size
    */
@@ -966,7 +966,7 @@ svn_cache__membuffer_cache_create(svn_me
       directory_size = group_count * sizeof(entry_group_t);
     }
 
-    for (seg = 0; seg < segment_count; ++seg)
+  for (seg = 0; seg < segment_count; ++seg)
     {
       /* allocate buffers and initialize cache members
        */



Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Julian Foad <ju...@wandisco.com>.
On Tue, 2011-05-10, Stefan Fuhrmann wrote:
> So, I found out what happened: The *IDE* (editor) complained
> about the assignment and thus I "fixed" it without checking the
> compiler log.
> 
> The compiler is happy without the cast and r1101616.

Thanks Stefan.

- Julian



Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Stefan Fuhrmann <eq...@web.de>.
On 10.05.2011 11:14, Branko Čibej wrote:
> On 10.05.2011 10:34, Stefan Fuhrmann wrote:
>> On 09.05.2011 18:43, Philip Martin wrote:
>>> stefan2@apache.org writes:
>>>
>>>> Author: stefan2
>>>> Date: Mon May  9 16:28:16 2011
>>>> New Revision: 1101091
>>>>     (svn_cache__membuffer_cache_create): formatting fixes; add
>>>> missing cast
>>>> -  c = apr_palloc(pool, segment_count * sizeof(*c));
>>>> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));
>>> Why is that cast necessary?
>>>
>> The Microsoft compiler issued a warning here and
>> the explicit cast silences it. Maybe, it's a C99 thing?
> Can't be, no Microsoft compiler has ever pretended to implement C99 ...
> besides, the rules for void* did not change between C90 and C99.
So, I found out what happened: The *IDE* (editor) complained
about the assignment and thus I "fixed" it without checking the
compiler log.

The compiler is happy without the cast and r1101616.

-- Stefan^2.

Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Branko Čibej <br...@e-reka.si>.
On 10.05.2011 10:34, Stefan Fuhrmann wrote:
> On 09.05.2011 18:43, Philip Martin wrote:
>> stefan2@apache.org writes:
>>
>>> Author: stefan2
>>> Date: Mon May  9 16:28:16 2011
>>> New Revision: 1101091
>>>    (svn_cache__membuffer_cache_create): formatting fixes; add
>>> missing cast
>>> -  c = apr_palloc(pool, segment_count * sizeof(*c));
>>> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));
>> Why is that cast necessary?
>>
> The Microsoft compiler issued a warning here and
> the explicit cast silences it. Maybe, it's a C99 thing?

Can't be, no Microsoft compiler has ever pretended to implement C99 ...
besides, the rules for void* did not change between C90 and C99.


-- Brane

Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Philip Martin <ph...@wandisco.com>.
Stefan Fuhrmann <eq...@web.de> writes:

> On 09.05.2011 18:43, Philip Martin wrote:
>> stefan2@apache.org writes:
>>
>>> Author: stefan2
>>> Date: Mon May  9 16:28:16 2011
>>> New Revision: 1101091
>>>    (svn_cache__membuffer_cache_create): formatting fixes; add missing cast
>>> -  c = apr_palloc(pool, segment_count * sizeof(*c));
>>> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));
>> Why is that cast necessary?
>>
> The Microsoft compiler issued a warning here and
> the explicit cast silences it. Maybe, it's a C99 thing?
> Curiously, it would not generate a warning before
> when the line read
>
> svn_membuffer_t *c = apr_palloc(...)

It's allowed by C99.  Sounds like a compiler bug.  We have dozens of
other calls of the form

  variable = apr_palloc(...);

Is this the only one that causes a warning?

-- 
Philip

Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Stefan Fuhrmann <eq...@web.de>.
On 09.05.2011 18:43, Philip Martin wrote:
> stefan2@apache.org writes:
>
>> Author: stefan2
>> Date: Mon May  9 16:28:16 2011
>> New Revision: 1101091
>>    (svn_cache__membuffer_cache_create): formatting fixes; add missing cast
>> -  c = apr_palloc(pool, segment_count * sizeof(*c));
>> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));
> Why is that cast necessary?
>
The Microsoft compiler issued a warning here and
the explicit cast silences it. Maybe, it's a C99 thing?
Curiously, it would not generate a warning before
when the line read

svn_membuffer_t *c = apr_palloc(...)

-- Stefan^2.

Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Philip Martin <ph...@wandisco.com>.
stefan2@apache.org writes:

> Author: stefan2
> Date: Mon May  9 16:28:16 2011
> New Revision: 1101091

>   (svn_cache__membuffer_cache_create): formatting fixes; add missing cast

> -  c = apr_palloc(pool, segment_count * sizeof(*c));
> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));

Why is that cast necessary?

-- 
Philip

Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Julian Foad <ju...@wandisco.com>.
stefan2@apache.org wrote:
> * subversion/libsvn_subr/cache-membuffer.c
>   (MIN_SEGMENT_SIZE): ensure that cache sizes > 4GB work
>   (svn_cache__membuffer_cache_create): formatting fixes; add missing cast

>    /* allocate cache as an array of segments / cache objects */
> -  c = apr_palloc(pool, segment_count * sizeof(*c));
> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));

Hi Stefan.  In contrast to C++, in C it's a handy convenience that we
don't need to cast "void *" pointers before assigning them.  This is the
only such cast in the code base.

- Julian




Re: svn commit: r1101091 - /subversion/trunk/subversion/libsvn_subr/cache-membuffer.c

Posted by Julian Foad <ju...@wandisco.com>.
stefan2@apache.org wrote:
> * subversion/libsvn_subr/cache-membuffer.c
>   (MIN_SEGMENT_SIZE): ensure that cache sizes > 4GB work
>   (svn_cache__membuffer_cache_create): formatting fixes; add missing cast

>    /* allocate cache as an array of segments / cache objects */
> -  c = apr_palloc(pool, segment_count * sizeof(*c));
> +  c = (svn_membuffer_t *)apr_palloc(pool, segment_count * sizeof(*c));

Hi Stefan.  In contrast to C++, in C it's a handy convenience that we
don't need to cast "void *" pointers before assigning them.  This is the
only such cast in the code base.

- Julian