From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aK5Mk-00059v-JX for qemu-devel@nongnu.org; Fri, 15 Jan 2016 09:28:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aK5Mj-0001pD-3R for qemu-devel@nongnu.org; Fri, 15 Jan 2016 09:28:38 -0500 Date: Fri, 15 Jan 2016 15:28:26 +0100 From: Kevin Wolf Message-ID: <20160115142826.GB3941@noname.redhat.com> References: <1452823763-4235-1-git-send-email-famz@redhat.com> <1452823763-4235-2-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1452823763-4235-2-git-send-email-famz@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: Fam Zheng Cc: berto@igalia.com, qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, mreitz@redhat.com 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. > return false; > } Kevin