From patchwork Wed Jun 28 05:53:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Wei W" X-Patchwork-Id: 9813533 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DC169603D7 for ; Wed, 28 Jun 2017 06:01:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0B3028462 for ; Wed, 28 Jun 2017 06:01:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C18EE28478; Wed, 28 Jun 2017 06:01:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 49F3F2845D for ; Wed, 28 Jun 2017 06:01:24 +0000 (UTC) Received: from localhost ([::1]:59346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQ62V-0006Gc-O5 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Jun 2017 02:01:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQ61l-0006D1-AW for qemu-devel@nongnu.org; Wed, 28 Jun 2017 02:00:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQ61i-0004Kp-6O for qemu-devel@nongnu.org; Wed, 28 Jun 2017 02:00:37 -0400 Received: from mga11.intel.com ([192.55.52.93]:7241) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQ61h-0004KP-Ug for qemu-devel@nongnu.org; Wed, 28 Jun 2017 02:00:34 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2017 23:00:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,274,1496127600"; d="scan'208"; a="1165462619" Received: from devel-ww.sh.intel.com ([10.239.48.97]) by fmsmga001.fm.intel.com with ESMTP; 27 Jun 2017 23:00:28 -0700 From: Wei Wang To: mst@redhat.com, jasowang@redhat.com, eblake@redhat.com, virtio-dev@lists.oasis-open.org, qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 13:53:20 +0800 Message-Id: <1498629200-35463-1-git-send-email-wei.w.wang@intel.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH v1] virtio-net: code cleanup 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: Wei Wang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use is_power_of_2(), and remove trailing "." from error_setg(). Signed-off-by: Wei Wang Reviewed-by: Eric Blake Reviewed-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 91eddaf..144169c 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1918,9 +1918,9 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) */ if (n->net_conf.rx_queue_size < VIRTIO_NET_RX_QUEUE_MIN_SIZE || n->net_conf.rx_queue_size > VIRTQUEUE_MAX_SIZE || - (n->net_conf.rx_queue_size & (n->net_conf.rx_queue_size - 1))) { + !is_power_of_2(n->net_conf.rx_queue_size)) { error_setg(errp, "Invalid rx_queue_size (= %" PRIu16 "), " - "must be a power of 2 between %d and %d.", + "must be a power of 2 between %d and %d", n->net_conf.rx_queue_size, VIRTIO_NET_RX_QUEUE_MIN_SIZE, VIRTQUEUE_MAX_SIZE); virtio_cleanup(vdev); @@ -1930,7 +1930,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp) n->max_queues = MAX(n->nic_conf.peers.queues, 1); if (n->max_queues * 2 + 1 > VIRTIO_QUEUE_MAX) { error_setg(errp, "Invalid number of queues (= %" PRIu32 "), " - "must be a positive integer less than %d.", + "must be a positive integer less than %d", n->max_queues, (VIRTIO_QUEUE_MAX - 1) / 2); virtio_cleanup(vdev); return;