apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: LP64/P64 model API issue #2
Date Wed, 18 May 2005 14:35:35 GMT
On Wed, May 18, 2005 at 02:41:48AM -0500, William Rowe wrote:
> At 09:01 AM 5/17/2005, Joe Orton wrote:
> >On Mon, May 16, 2005 at 01:39:20PM -0500, William Rowe wrote:
> >> Issue  #1; How to manipulate nelts in apr_table_entry?
> >> 
> >> We can preserve the existing behavior of nelts, defining it as
> >> a simple int.  A few casts are required out of the result of some
> >> pointer arithmetic.
> >
> >Can you explain what casts are needed exactly, and why?
> 
> It's embodied by the patch below - the delta of two pointer
> offsets result in a size_t (by definition).  On LP64/P64, the
> sizeof(int) < sizeof(size_t).

The code is really fine in both places - you're really out here to fix
compiler warnings, right?  But a different compiler could now issue a
new warning in table_mergesort:

    for (i = 0; i + 1 < n; i += 2) {

for comparison of (apr_size_t) i and (int) n since they have both
different size and signedness.  So that's not improved the code quality
a great deal really.

> Author: wrowe
> Date: Mon May 16 14:49:49 2005
> New Revision: 170468
> 
> URL: http://svn.apache.org/viewcvs?rev=170468&view=rev
> Log:
> 
>   We play pointer math with local 'i', so it must be apr_size_t.
> 
>   Until we decide otherwise, cast the pointer math result back to an
>   int for a nelts result.
> 
> Modified:
>     apr/apr/trunk/tables/apr_tables.c
> 
> Modified: apr/apr/trunk/tables/apr_tables.c
> URL: http://svn.apache.org/viewcvs/apr/apr/trunk/tables/apr_tables.c?rev=170468&r1=170467&r2=170468&view=diff
> ==============================================================================
> --- apr/apr/trunk/tables/apr_tables.c (original)
> +++ apr/apr/trunk/tables/apr_tables.c Mon May 16 14:49:49 2005
> @@ -970,7 +970,7 @@
>       */
>      apr_table_entry_t **values_tmp =
>          (apr_table_entry_t **)apr_palloc(pool, n * sizeof(apr_table_entry_t*));
> -    int i;
> +    apr_size_t i;
>      int blocksize;
>  
>      /* First pass: sort pairs of elements (blocksize=1) */
> @@ -1156,7 +1156,7 @@
>                  *dst++ = *src;
>              }
>          } while (++src < last_elt);
> -        t->a.nelts -= (last_elt - dst);
> +        t->a.nelts -= (int)(last_elt - dst);
>      }
>  
>      table_reindex(t);
> 

Mime
View raw message