From patchwork Wed May 6 12:07:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 468895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 577561402AB for ; Wed, 6 May 2015 22:10:28 +1000 (AEST) Received: from localhost ([::1]:44619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypy9i-0001Ec-0n for incoming@patchwork.ozlabs.org; Wed, 06 May 2015 08:10:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypy7D-0005mD-9d for qemu-devel@nongnu.org; Wed, 06 May 2015 08:07:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ypy77-00024k-Co for qemu-devel@nongnu.org; Wed, 06 May 2015 08:07:51 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:49159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ypy77-00024d-3G for qemu-devel@nongnu.org; Wed, 06 May 2015 08:07:45 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 May 2015 13:07:44 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 6 May 2015 13:07:42 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 705D217D805A for ; Wed, 6 May 2015 13:08:27 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t46C7g9G4522308 for ; Wed, 6 May 2015 12:07:42 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t46C7ebp015243 for ; Wed, 6 May 2015 06:07:41 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t46C7djF015209; Wed, 6 May 2015 06:07:39 -0600 Received: from bahia.huguette.org (sig-9-79-87-99.de.ibm.com [9.79.87.99]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 24D31220504; Wed, 6 May 2015 14:07:38 +0200 (CEST) From: Greg Kurz To: Jason Wang , Stefan Hajnoczi , "Michael S. Tsirkin" Date: Wed, 06 May 2015 14:07:37 +0200 Message-ID: <20150506120737.8607.30158.stgit@bahia.huguette.org> In-Reply-To: <20150506120729.8607.23404.stgit@bahia.huguette.org> References: <20150506120729.8607.23404.stgit@bahia.huguette.org> User-Agent: StGit/0.17-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15050612-0017-0000-0000-000003F2A74C X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.110 Cc: qemu-devel@nongnu.org, virtualization@lists.linux-foundation.org Subject: [Qemu-devel] [PATCH RFC 1/7] virtio: relax feature check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Unlike with add and clear, there is no valid reason to abort when checking for a feature. It makes more sense to return false (i.e. the feature bit isn't set). This is exactly what __virtio_has_feature() does if fbit >= 32. This allows to introduce code that is aware about new 64-bit features like VIRTIO_F_VERSION_1, even if they are still not implemented. Signed-off-by: Greg Kurz --- include/hw/virtio/virtio.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index d95f8b6..6ef70f1 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -233,7 +233,6 @@ static inline void virtio_clear_feature(uint32_t *features, unsigned int fbit) static inline bool __virtio_has_feature(uint32_t features, unsigned int fbit) { - assert(fbit < 32); return !!(features & (1 << fbit)); }