From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQdnx-0004io-GW for qemu-devel@nongnu.org; Tue, 23 Oct 2012 08:42:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQdnq-0004iG-SJ for qemu-devel@nongnu.org; Tue, 23 Oct 2012 08:41:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60175) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQdnq-0004iA-KN for qemu-devel@nongnu.org; Tue, 23 Oct 2012 08:41:50 -0400 Date: Tue, 23 Oct 2012 10:42:23 -0200 From: Luiz Capitulino Message-ID: <20121023104223.41ad0081@doriath.home> In-Reply-To: <50862DBD.4010403@linux.vnet.ibm.com> References: <1350838081-6351-1-git-send-email-lilei@linux.vnet.ibm.com> <1350838081-6351-2-git-send-email-lilei@linux.vnet.ibm.com> <5085536D.3010502@redhat.com> <50862DBD.4010403@linux.vnet.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/5] qemu-char: Add new char backend CircularMemCharDriver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lei Li Cc: blauwirbel@gmail.com, aliguori@us.ibm.com, qemu-devel@nongnu.org On Tue, 23 Oct 2012 13:40:13 +0800 Lei Li wrote: > >> +static int cirmem_chr_write(CharDriverState *chr, const uint8_t *buf, int len) > >> +{ > >> + CirMemCharDriver *d = chr->opaque; > >> + int i; > >> + > >> + if (len < 0) { > >> + return -1; > >> + } > >> + > >> + /* The size should be a power of 2. */ > > Shouldn't you enforce that, then? > > Yes, it has been checked when open the CirMemChar backend in patch 2/5, > as code below: > > if (d->size & (d->size -1)) { > return NULL; > } You could add an assert() in cirmem_chr_write() then.