Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2059143pxb; Fri, 25 Mar 2022 10:21:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSPkV64wqeMf0rLvBgiIi+CdqLZaxPKMifj2kOK6Ew+Meg7ixpYbeDlpFa8AxM8dHhmuCA X-Received: by 2002:a05:6830:4088:b0:5b2:6287:59e2 with SMTP id x8-20020a056830408800b005b2628759e2mr4830003ott.289.1648228895362; Fri, 25 Mar 2022 10:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648228895; cv=none; d=google.com; s=arc-20160816; b=DOzrhv5/BrkqU+1KBSuenc7ifuF7Xd+yRxtkGWviqhFKm2GThjOapJby1/bUGkQSSV TMuKkITDkWk1d1X+98sWtbm9sngx9AHH/NBwP+J4tnRhLtKslFtNAQdxm0YBp3JMfSL9 DV2Yx6G88ipBjJpTnVNrWmdWGGfsJboszbdgiymNaE6mtoH6hLLwg43K2IyM9pxZrMEw IuKJfNBIyyK7vjkrtumRpP4csaGgPaj9keJuD6xhUWH9zoSJghmVcFAFrdYTP10NzYMx 0mT3zmOPEoFq8z2L7aTTanfN1qj7O5O26t/oreN7OIid4NVo4zHdCvc/kfHP7QXre4Qp DyUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+jBes5m/e131YoblZZDRcsU52MDg1rSadlaC+RwD+To=; b=VQHvp0JPXfT1Thq4OL6QM5F4qGVAahii4jCWkhFYS3M4SsSY5blbI3PyYhCOb8/YBq CI9cs8XWCzyyvinhyDGWZbAN3SW9E6LYARD97ZcyZFFr1bNd6XZj7d+Ia0i5yxREgiHG BNv0xKiD7erMloa+VygqOKgC/8qT1vE8WeTftnuzEGMgjVKIEn/coFyNmCJioqNa1Emu +Tc14BU7uiPcnXzSGsl8zhYwNar2w+vn4MysyW4NZ40Vn2YIVFKgBS8pwRwnklwjw/XD f5ExtOKNV+Z5B0gyS6YAQzuzQgp8aV13BHtExxSZwR9U28oQMRUAzXiiDBM4S7+6ObZz X0Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OpDuTpMt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bl38-20020a05680830a600b002ef0c3475ddsi2738772oib.93.2022.03.25.10.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 10:21:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=OpDuTpMt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4A68ED9F5; Fri, 25 Mar 2022 10:18:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345477AbiCXHdy (ORCPT + 99 others); Thu, 24 Mar 2022 03:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348816AbiCXHdO (ORCPT ); Thu, 24 Mar 2022 03:33:14 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DA198F7C; Thu, 24 Mar 2022 00:31:42 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id a8so7325831ejc.8; Thu, 24 Mar 2022 00:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+jBes5m/e131YoblZZDRcsU52MDg1rSadlaC+RwD+To=; b=OpDuTpMtzE0RhGUG1pR+nWeI8o4UdMCn8dQbtGo4v9iN7ipB4uFu5TtqOgsDMnbQzg 5WByTzpHx4HUeR2aygQUqWZivHblzmnQa3TSOVGXaqEVoDWMB10qb8N33crRMOdHIr6M OJSELDjXDkVT8uxqO6kauRy8KDSwk0AUvG/6fcnoBJ/8/i1IIHdGuQdc4St7F4x2xV7a 1XqfulRiO0Tn+U3+AdANPPoaAvOtVEE5BVtaYH/3vZNeRG6qAzrag5p2BeupNmqs6oWj r6dYiCGfdF0LcQlDm3eSO1yniwkE7hKMZaL5X6ykXmZdEUOGn9r4uoAP2GTrWHlGv9mk PJAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+jBes5m/e131YoblZZDRcsU52MDg1rSadlaC+RwD+To=; b=gUJmlPvmvVu9n1d253hmlyzd39p5uAXpSWq4/rzxAE+5RkHjDIiaX5azgTKRccqzkr GKpY98dPq8JkjTFPRZ4dd+iu5qMowLyzo/FAjMvFYGperIgeROd+kbvTbqVJ9/D2jkNn buVBvj5a68bWhPU/JPdjHDMT0FJ55o1ngJkG1mN+6bN0rtQiFSAEPkeoNPMCNHFJBaLD 1ynEkGXmlZqYgLd0JX9MC1J/bqp7BUG4TXfkRs2eLNqeWZg8NGjfPSQIpqpTOeD2Vodi HVyx4FhGCmiCcHVuU4W9uqI00aBhTqN6YoQ+SGNe+cJJqX1pmUm8ni4ZftVYw8+MaXP1 0r6w== X-Gm-Message-State: AOAM532MTNZKxfr7JdRCYX3CvUDQML/cs3oiNtgm6MZvMydOX9+rsH5J fLWHDaZuY46zzQUQRqEPK0w= X-Received: by 2002:a17:906:a1c8:b0:6da:a635:e402 with SMTP id bx8-20020a170906a1c800b006daa635e402mr4201959ejb.598.1648107101128; Thu, 24 Mar 2022 00:31:41 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id gv9-20020a170906f10900b006d7128b2e6fsm766705ejb.162.2022.03.24.00.31.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:31:40 -0700 (PDT) From: Jakob Koschel To: Alex Williamson Cc: Cornelia Huck , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] vfio/spapr_tce: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:31:10 +0100 Message-Id: <20220324073110.66125-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ Signed-off-by: Jakob Koschel --- drivers/vfio/vfio_iommu_spapr_tce.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 708a95e61831..f64ef767909a 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -104,8 +104,7 @@ static long tce_iommu_unregister_pages(struct tce_container *container, __u64 vaddr, __u64 size) { struct mm_iommu_table_group_mem_t *mem; - struct tce_iommu_prereg *tcemem; - bool found = false; + struct tce_iommu_prereg *tcemem = NULL, *iter; long ret; if ((vaddr & ~PAGE_MASK) || (size & ~PAGE_MASK)) @@ -115,14 +114,14 @@ static long tce_iommu_unregister_pages(struct tce_container *container, if (!mem) return -ENOENT; - list_for_each_entry(tcemem, &container->prereg_list, next) { - if (tcemem->mem == mem) { - found = true; + list_for_each_entry(iter, &container->prereg_list, next) { + if (iter->mem == mem) { + tcemem = iter; break; } } - if (!found) + if (!tcemem) ret = -ENOENT; else ret = tce_iommu_prereg_free(container, tcemem); @@ -1330,19 +1329,19 @@ static void tce_iommu_detach_group(void *iommu_data, { struct tce_container *container = iommu_data; struct iommu_table_group *table_group; - bool found = false; - struct tce_iommu_group *tcegrp; + struct tce_iommu_group *tcegrp = NULL; + struct tce_iommu_group *iter; mutex_lock(&container->lock); - list_for_each_entry(tcegrp, &container->group_list, next) { - if (tcegrp->grp == iommu_group) { - found = true; + list_for_each_entry(iter, &container->group_list, next) { + if (iter->grp == iommu_group) { + tcegrp = iter; break; } } - if (!found) { + if (!tcegrp) { pr_warn("tce_vfio: detaching unattached group #%u\n", iommu_group_id(iommu_group)); goto unlock_exit; base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1