Received: from eggs.gnu.org ([208.118.235.92]:57592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYy3W-0007Yj-Fz for qemu-devel@nongnu.org; Sun, 05 May 2013 08:28:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UYy3V-0005oA-6b for qemu-devel@nongnu.org; Sun, 05 May 2013 08:28:42 -0400 Received: from zose-mta15.web4all.fr ([178.33.204.94]:35111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UYy3V-0005nn-1L for qemu-devel@nongnu.org; Sun, 05 May 2013 08:28:41 -0400 Message-ID: <51865075.6040000@tribudubois.net> Date: Sun, 05 May 2013 14:28:37 +0200 From: Jean-Christophe DUBOIS MIME-Version: 1.0 References: <5185D8FF.7030904@tribudubois.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/4] Add i.MX I2C controller driver. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite Cc: Peter Maydell , peter.chubb@nicta.com.au, qemu-devel@nongnu.org, afaerber@suse.de On 05/05/2013 01:53 PM, Peter Crosthwaite wrote: > Hi Peter, > > On Sun, May 5, 2013 at 9:41 PM, Peter Maydell wrote: >> On 5 May 2013 11:53, Peter Crosthwaite wrote: >>> On Sun, May 5, 2013 at 8:47 PM, Peter Maydell wrote: >>>> On 5 May 2013 04:58, Jean-Christophe DUBOIS wrote: >>>>> no extract16() macro spotted. >>>>> Should one be added? >>>> There's no need for one -- just use extract32. The only >>>> reason for having a separate extract64 is to avoid doing >>>> 64 bit arithmetic when we don't have to, I think. >>>> >>> perhaps a quick: >>> >>> #define extract16(a, b, c) (uint16_t)extract32((uint16_t)(a), (b), (c)) >>> >>> would keep the 16bit device code explicit and clean? Save on >>> dummy casts in certain situations as well (but not this one). >> Hmm, what situations would ever require a cast of the result >> or the input of extract32? >> > The one off the top of my head: > > fprintf(stderr, "your 16 field is :%" PRIx16 "\n", extract16(foo, bar, baz)); > > Otherwise you would have to match PRIx32 to extract 16 which is clumsy. > > But aren't there there some other varargs situations that may require > casts as well? > > As for the input cast, I got nothin, I just put it in there for > completeness. Meet you half way and drop the input cast and keep the > output? > > Regards, > Peter I will use extract32() for now. JC > >> -- PMM >>