From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MjUJp-0001bt-8q for qemu-devel@nongnu.org; Fri, 04 Sep 2009 04:38:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MjUJj-0001Wi-60 for qemu-devel@nongnu.org; Fri, 04 Sep 2009 04:38:51 -0400 Received: from [199.232.76.173] (port=38838 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjUJi-0001WT-Sz for qemu-devel@nongnu.org; Fri, 04 Sep 2009 04:38:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53792) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MjUJi-0000vn-Ek for qemu-devel@nongnu.org; Fri, 04 Sep 2009 04:38:46 -0400 Date: Fri, 4 Sep 2009 14:07:49 +0530 From: Amit Shah Message-ID: <20090904083749.GA22230@amit-x200.redhat.com> References: <1251982412-11870-1-git-send-email-amit.shah@redhat.com> <1251982412-11870-2-git-send-email-amit.shah@redhat.com> <1251982412-11870-3-git-send-email-amit.shah@redhat.com> <1251982412-11870-4-git-send-email-amit.shah@redhat.com> <20090903142605.GB8613@amit-x200.redhat.com> <20090903144255.GB13361@amit-x200.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] Re: [PATCH 2/2] virtio-console: Add interface for generic guest-host communication List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org On (Thu) Sep 03 2009 [17:20:44], Juan Quintela wrote: > Amit Shah wrote: > > Hi > > >> > > +static void virtio_console_set_port_active(uint32_t idx) > >> > > +{ > >> > > + int i = 0; > >> > > + > >> > > + while (idx / 32) { > >> > > + i++; > >> > > + idx -= 32; > >> > > + } > >> > > >> > It is just me, or you are doing a division + modulus in a very strange way? > >> > > >> > i = idx / 32; > >> > idx = idx % 32; > >> > > >> > ??? > > > > Er, sorry I left this out. > > > > That won't work for MAX_PORTS > 32. > > Why not? After a good night's sleep, I see that I was wrong :-) You're right and I don't remember why I did it this way instead of just using % from the start. Maybe I had a different way of storing it back then; it's been a long time. I also saw that I was wrong about the casts: > > > +/* Readiness of the guest to accept data on a port */ > > > +static int vcon_can_read(void *opaque) > > > +{ > > > + VirtIOConsolePort *port = (VirtIOConsolePort *) opaque; > > > > Cast is not needed here. > This is original code that I've not modified (just moved around). > But you're right; I could do that in this patch itself. These were indeed introduced by me (and are now corrected). Thanks! Amit