From nobody Tue Jun 23 09:17:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB17C433EF for ; Tue, 8 Mar 2022 09:54:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345530AbiCHJzf (ORCPT ); Tue, 8 Mar 2022 04:55:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235300AbiCHJze (ORCPT ); Tue, 8 Mar 2022 04:55:34 -0500 X-Greylist: delayed 182 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 08 Mar 2022 01:54:35 PST Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6492C3F33B; Tue, 8 Mar 2022 01:54:35 -0800 (PST) Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee762272721fbf-9b593; Tue, 08 Mar 2022 17:51:31 +0800 (CST) X-RM-TRANSID: 2ee762272721fbf-9b593 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from localhost.localdomain (unknown[223.108.79.97]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee7622727171ce-2a1ab; Tue, 08 Mar 2022 17:51:31 +0800 (CST) X-RM-TRANSID: 2ee7622727171ce-2a1ab From: jianchunfu To: alex.williamson@redhat.com Cc: cohuck@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, jianchunfu Subject: [PATCH] drivers:vfio: make the logic cleaner with braket Date: Tue, 8 Mar 2022 17:49:46 +0800 Message-Id: <20220308094946.139059-1-jianchunfu@cmss.chinamobile.com> X-Mailer: git-send-email 2.18.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use braket to avoid identifying operators in function vfio_iova_dirty_bitmap() and vfio_dma_do_unmap() when there are too many field values. Signed-off-by: jianchunfu --- drivers/vfio/vfio_iommu_type1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type= 1.c index 9394aa944..199547012 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -1251,7 +1251,7 @@ static int vfio_iova_dirty_bitmap(u64 __user *bitmap,= struct vfio_iommu *iommu, return -EINVAL; =20 dma =3D vfio_find_dma(iommu, iova + size - 1, 0); - if (dma && dma->iova + dma->size !=3D iova + size) + if (dma && (dma->iova + dma->size) !=3D (iova + size)) return -EINVAL; =20 for (n =3D rb_first(&iommu->dma_list); n; n =3D rb_next(n)) { @@ -1363,7 +1363,7 @@ static int vfio_dma_do_unmap(struct vfio_iommu *iommu, goto unlock; =20 dma =3D vfio_find_dma(iommu, iova + size - 1, 0); - if (dma && dma->iova + dma->size !=3D iova + size) + if (dma && (dma->iova + dma->size) !=3D (iova + size)) goto unlock; } =20 @@ -2958,7 +2958,7 @@ static int vfio_iommu_type1_dirty_pages(struct vfio_i= ommu *iommu, ret =3D -EINVAL; goto out_unlock; } - if (!range.size || range.size & (iommu_pgsize - 1)) { + if (!range.size || (range.size & (iommu_pgsize - 1))) { ret =3D -EINVAL; goto out_unlock; } --=20 2.18.4