Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 68372 invoked from network); 18 May 2005 15:13:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 May 2005 15:13:53 -0000 Received: (qmail 95705 invoked by uid 500); 18 May 2005 14:57:40 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 95558 invoked by uid 500); 18 May 2005 14:57:38 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 95442 invoked by uid 99); 18 May 2005 14:57:36 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of jorton@redhat.com designates 66.187.233.31 as permitted sender) Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 18 May 2005 07:57:28 -0700 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j4IEZgTW030542 for ; Wed, 18 May 2005 10:35:42 -0400 Received: from radish.cambridge.redhat.com (radish.cambridge.redhat.com [172.16.18.90]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j4IEZgO23469 for ; Wed, 18 May 2005 10:35:42 -0400 Received: from radish.cambridge.redhat.com (localhost.localdomain [127.0.0.1]) by radish.cambridge.redhat.com (8.13.1/8.12.7) with ESMTP id j4IEZa0i019575 for ; Wed, 18 May 2005 15:35:36 +0100 Received: (from jorton@localhost) by radish.cambridge.redhat.com (8.13.1/8.12.10/Submit) id j4IEZZnD019574 for dev@apr.apache.org; Wed, 18 May 2005 15:35:35 +0100 Date: Wed, 18 May 2005 15:35:35 +0100 From: Joe Orton To: dev@apr.apache.org Subject: Re: LP64/P64 model API issue #2 Message-ID: <20050518143535.GA12745@redhat.com> Mail-Followup-To: dev@apr.apache.org References: <6.2.1.2.2.20050516133724.07370a90@pop3.rowe-clan.net> <20050517140136.GB5421@redhat.com> <6.2.1.2.2.20050518023918.04b1d790@pop3.rowe-clan.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6.2.1.2.2.20050518023918.04b1d790@pop3.rowe-clan.net> User-Agent: Mutt/1.4.1i X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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); >