From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MbbWw-00061A-9b for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:43:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MbbWr-0005tZ-6L for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:43:49 -0400 Received: from [199.232.76.173] (port=58901 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MbbWq-0005tI-Tx for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:43:45 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45996) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MbbWp-0005Bv-To for qemu-devel@nongnu.org; Thu, 13 Aug 2009 10:43:44 -0400 Message-ID: <4A84269C.4030308@redhat.com> Date: Thu, 13 Aug 2009 17:43:40 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1250171428-29308-1-git-send-email-lcapitulino@redhat.com> <1250171428-29308-24-git-send-email-lcapitulino@redhat.com> <4A841C52.7050805@redhat.com> <20090813111821.63c6e3ec@doriath> In-Reply-To: <20090813111821.63c6e3ec@doriath> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 23/29] monitor: fail when 'i' type is greater than 32-bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org On 08/13/2009 05:18 PM, Luiz Capitulino wrote: > On Thu, 13 Aug 2009 16:59:46 +0300 > Avi Kivity wrote: > > >> On 08/13/2009 04:50 PM, Luiz Capitulino wrote: >> >>> The 'i' argument type is for 32-bit only and most handlers >>> will use an 'int' to store its value. >>> >>> It's better to fail gracefully when the user enters a value >>> greater than 32-bit than to get subtle casting bugs. >>> >>> Signed-off-by: Luiz Capitulino >>> --- >>> monitor.c | 6 ++++++ >>> 1 files changed, 6 insertions(+), 0 deletions(-) >>> >>> diff --git a/monitor.c b/monitor.c >>> index e736de4..2052c00 100644 >>> --- a/monitor.c >>> +++ b/monitor.c >>> @@ -2820,6 +2820,12 @@ static const mon_cmd_t *monitor_parse_command(Monitor *mon, >>> } >>> if (get_expr(mon,&val,&p)) >>> goto fail; >>> + /* Check if 'i' is greater than 32-bit */ >>> + if ((c == 'i')&& ((val>> 32)& 0xffffffff)) { >>> + monitor_printf(mon, "\'%s\' has failed: ", cmdname); >>> + monitor_printf(mon, "integer is for 32-bit values\n"); >>> + goto fail; >>> + } >>> qdict_add_qint(qdict, key, qint_from_int64(val)); >>> } >>> >>> >> What about the commands that do allow 64-bit values, like memory inspection? >> > > They work with the long type ('l'), so the check will be false > as it checks for 'i'. > Ah, ok. -- error compiling committee.c: too many arguments to function