From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKyK7-0000aT-9G for qemu-devel@nongnu.org; Sun, 17 Jan 2016 20:09:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKyK6-00061p-EW for qemu-devel@nongnu.org; Sun, 17 Jan 2016 20:09:35 -0500 Date: Mon, 18 Jan 2016 09:09:22 +0800 From: Fam Zheng Message-ID: <20160118010921.GA22366@ad.usersys.redhat.com> References: <1452823763-4235-1-git-send-email-famz@redhat.com> <1452823763-4235-2-git-send-email-famz@redhat.com> <20160115142826.GB3941@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160115142826.GB3941@noname.redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 1/2] blockdev: Error out on negative throttling option values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: mreitz@redhat.com, berto@igalia.com, Markus Armbruster , qemu-block@nongnu.org, qemu-devel@nongnu.org On Fri, 01/15 15:28, Kevin Wolf wrote: > Am 15.01.2016 um 03:09 hat Fam Zheng geschrieben: > > The implicit casting from unsigned int to double changes negative values > > into large positive numbers and accepts them. We should instead print > > an error. > > > > Check the number range so this case is caught and reported. > > > > Signed-off-by: Fam Zheng > > Reviewed-by: Max Reitz > > --- > > blockdev.c | 3 ++- > > include/qemu/throttle.h | 2 ++ > > util/throttle.c | 16 ++++++---------- > > 3 files changed, 10 insertions(+), 11 deletions(-) > > > > diff --git a/blockdev.c b/blockdev.c > > index 2df0c6d..b925e5d 100644 > > --- a/blockdev.c > > +++ b/blockdev.c > > @@ -348,7 +348,8 @@ static bool check_throttle_config(ThrottleConfig *cfg, Error **errp) > > } > > > > if (!throttle_is_valid(cfg)) { > > - error_setg(errp, "bps/iops/maxs values must be 0 or greater"); > > + error_setg(errp, "bps/iops/max values must be within [0, %" PRId64 > > + ")", (int64_t)THROTTLE_VALUE_MAX); > > I think that should be "]". If you agree, I'll fix it up while applying. Yes, that's right. Thanks. Fam > > > return false; > > } > > Kevin >