From nobody Mon Feb 9 04:09:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503581269924383.9130748522815; Thu, 24 Aug 2017 06:27:49 -0700 (PDT) Received: from localhost ([::1]:48636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dksAm-0004Tl-66 for importer@patchew.org; Thu, 24 Aug 2017 09:27:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dks90-0003JQ-G1 for qemu-devel@nongnu.org; Thu, 24 Aug 2017 09:25:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dks8w-0003U8-GH for qemu-devel@nongnu.org; Thu, 24 Aug 2017 09:25:58 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:53891) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dks8w-000338-1G; Thu, 24 Aug 2017 09:25:54 -0400 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1dks8H-0002oP-U7; Thu, 24 Aug 2017 15:25:14 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1dks80-0007cs-Po; Thu, 24 Aug 2017 16:24:56 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=iI5TjUxdwjsPS/HExeGQ1+SUPyfdc3l8cWNmfwaNK3Y=; b=NpEk6IIJ5bm0VT2cQjMQnHfIkNy6b2cBP9M+3c6pk8d1AOuUfZX5C4CgGJESTO2k7RnqiIkDcKMMnciOVKlXYCEwm4+SkTUZMGjsEoeUvaPLZgFY+RqW9QsVGqhn2Htz58XZYRbcRu+O/KqwYEL/3OVuSfgZN98bPQVFuTdRaNKjc7UBFtSCNhOqEja25j9KEk0HP+NJhezIGVMYjlyFtezaDnmeipnvpX683GySxL6zClxxc3EK66oQLNxOcTr4iKg3aIwx1XMHYi4vFpfisxdRpBQPIou+14xq0MKG7FCy+n0KCaSEzTLvm0u8GLbXpuuCLOrd0K7zxZ8h9yjunQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 16:24:45 +0300 Message-Id: <763ffc40a26b17d54cf93f5a999e4656049fcf0c.1503580370.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH v2 3/7] throttle: Make throttle_is_valid() a bit less verbose X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alberto Garcia , Markus Armbruster , qemu-block@nongnu.org, Manos Pitsidianakis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use a pointer to the bucket instead of repeating cfg->buckets[i] all the time. This makes the code more concise and will help us expand the checks later and save a few line breaks. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake --- util/throttle.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/util/throttle.c b/util/throttle.c index 9a6bda813c..bde56fe3de 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -324,32 +324,31 @@ bool throttle_is_valid(ThrottleConfig *cfg, Error **e= rrp) } =20 for (i =3D 0; i < BUCKETS_COUNT; i++) { - if (cfg->buckets[i].avg < 0 || - cfg->buckets[i].max < 0 || - cfg->buckets[i].avg > THROTTLE_VALUE_MAX || - cfg->buckets[i].max > THROTTLE_VALUE_MAX) { + LeakyBucket *bkt =3D &cfg->buckets[i]; + if (bkt->avg < 0 || bkt->max < 0 || + bkt->avg > THROTTLE_VALUE_MAX || bkt->max > THROTTLE_VALUE_MAX= ) { error_setg(errp, "bps/iops/max values must be within [0, %lld]= ", THROTTLE_VALUE_MAX); return false; } =20 - if (!cfg->buckets[i].burst_length) { + if (!bkt->burst_length) { error_setg(errp, "the burst length cannot be 0"); return false; } =20 - if (cfg->buckets[i].burst_length > 1 && !cfg->buckets[i].max) { + if (bkt->burst_length > 1 && !bkt->max) { error_setg(errp, "burst length set without burst rate"); return false; } =20 - if (cfg->buckets[i].max && !cfg->buckets[i].avg) { + if (bkt->max && !bkt->avg) { error_setg(errp, "bps_max/iops_max require corresponding" " bps/iops values"); return false; } =20 - if (cfg->buckets[i].max && cfg->buckets[i].max < cfg->buckets[i].a= vg) { + if (bkt->max && bkt->max < bkt->avg) { error_setg(errp, "bps_max/iops_max cannot be lower than bps/io= ps"); return false; } --=20 2.11.0