From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhHPw-0003Ej-Li for qemu-devel@nongnu.org; Thu, 14 Jul 2011 04:37:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QhHPu-0001TB-JH for qemu-devel@nongnu.org; Thu, 14 Jul 2011 04:37:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QhHPu-0001Sy-0N for qemu-devel@nongnu.org; Thu, 14 Jul 2011 04:37:06 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6E8b5ZZ012779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 14 Jul 2011 04:37:05 -0400 Message-ID: <4E1EAAAE.4060106@redhat.com> Date: Thu, 14 Jul 2011 10:37:02 +0200 From: Gerd Hoffmann MIME-Version: 1.0 References: <1310568597-24181-1-git-send-email-alevy@redhat.com> <1310568597-24181-6-git-send-email-alevy@redhat.com> In-Reply-To: <1310568597-24181-6-git-send-email-alevy@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCHv4 05/11] qxl: add io_port_to_string List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alon Levy Cc: yhalperi@redhat.com, qemu-devel@nongnu.org On 07/13/11 16:49, Alon Levy wrote: > Signed-off-by: Alon Levy > --- > hw/qxl.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 60 insertions(+), 1 deletions(-) > > diff --git a/hw/qxl.c b/hw/qxl.c > index e41f8cc..2ecc932 100644 > --- a/hw/qxl.c > +++ b/hw/qxl.c > @@ -408,6 +408,64 @@ static const char *qxl_mode_to_string(int mode) > return "INVALID"; > } > > +static const char *io_port_to_string(uint32_t io_port) > +{ > + if (io_port>= QXL_IO_RANGE_SIZE) { > + return "out of range"; > + } > + switch (io_port) { > + case QXL_IO_NOTIFY_CMD: > + return "QXL_IO_NOTIFY_CMD"; > + case QXL_IO_NOTIFY_CURSOR: > + return "QXL_IO_NOTIFY_CURSOR"; That becomes alot more readable when using a c99 array for it: static const char *io_port_names[QXL_IO_RANGE_SIZE] = { [ QXL_IO_NOTIFY_CMD ] = "notify-cmd", [ QXL_IO_NOTIFY_CURSOR ] = "notify-cursor", [ ... ] };