From nobody Sat Jun 20 02:12:19 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 CF327C433FE for ; Thu, 24 Mar 2022 07:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245176AbiCXHbo (ORCPT ); Thu, 24 Mar 2022 03:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348570AbiCXHbf (ORCPT ); Thu, 24 Mar 2022 03:31:35 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1DFE99682; Thu, 24 Mar 2022 00:30:03 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id d10so7311307eje.10; Thu, 24 Mar 2022 00:30:03 -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=41pszt+PybnYgUfx9vODac1IhLaztrq7kY7kXvf9mWE=; b=W75d1bj3/HxEocX67AESJvny7BilgO6/7lbivPiE3r4fOBeapIiA75UE/w4WB2mj5S rV4FrD2YP1BuVYTq5QIsCmFhcdwSQJpFIjv7aV1akR0ZF/U1krZMcKAr5LIQ6XAMPM1w 35SUvw17LHJvsy4eJtBTsKu2nqf3HlTN+lIePzCOovyk2sTlcFSQ4TY3BVPV+vbZT8Dq EKTP4dcw/q1zUg6OhJaA4WAZ3K8dd4zGKcxf/slB0oiPhPx9qmRKkDNufV1LEJbMf0Vk moAnOYySm5bSqtv0NQQ39Yb5TqBR0rGOodNmG+U99BXGHOv8oie3O5rvCKYGcYLjSByn O/Zg== 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=41pszt+PybnYgUfx9vODac1IhLaztrq7kY7kXvf9mWE=; b=7cBJl6sOMmXIOxD78gHtT4LZyis5S4vKwRrujqgCfTetxqihJvpK3ONx2a8QxJn2uE 55HKnmzKlLkp2rLFZqudL9aRJirqCfCiCUrRoKJ107CCA3IR+r08wLZWb5G4LdGRxrVA yXrlHHlvz9cuUNcE0foxtVw07EabeQXn8Z2obnMDJubb9yN0eC47gLV2003sSXzWXUiS 6wtanMail0xIzbnJPA41R+OmygoSA4RfIbqhD1GH1g+dJ1sC38B8gRa2tgGtSboOjSRa yz+JhVLL+yxGA//UzwUX1MdlCV2MOWrgfbXMT4be/sl8AEamJTltWqLNZoN9AjPmdWkt cDOA== X-Gm-Message-State: AOAM530YrgVlrlaUpDOFXYU6PeMptdIGTaWOLwS2wa8vUnmTFlR/qBld Dg7P26uCLoSDlMEwQ3bX3YInL0PmbOC7CRyl X-Google-Smtp-Source: ABdhPJypvh4h6q3BYO/WNfs15tnV/nCxMBcLKYfEtbu2nrSmu2Bj2OEgrzj3UAcqRGrX+RJ6G4I3+A== X-Received: by 2002:a17:906:2a50:b0:6da:ed06:b029 with SMTP id k16-20020a1709062a5000b006daed06b029mr4301820eje.506.1648107002288; Thu, 24 Mar 2022 00:30:02 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id q9-20020a17090609a900b006cd30a3c4f0sm787085eje.147.2022.03.24.00.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:30:01 -0700 (PDT) From: Jakob Koschel To: Dan Williams Cc: Vishal Verma , Dave Jiang , Ira Weiny , "Rafael J. Wysocki" , Len Brown , Zou Wei , Bjorn Helgaas , nvdimm@lists.linux.dev, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] tools/testing/nvdimm: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:29:52 +0100 Message-Id: <20220324072952.65489-1-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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-=3DwgRr_D8CB-D9Kg-c=3DEHreAsk5SqXPwr= 9Y7k9sA6cWXJ6w@mail.gmail.com/ Signed-off-by: Jakob Koschel --- drivers/acpi/nfit/mce.c | 11 +++++------ tools/testing/nvdimm/test/iomap.c | 18 +++++++++--------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/acpi/nfit/mce.c b/drivers/acpi/nfit/mce.c index ee8d9973f60b..6d11506e871e 100644 --- a/drivers/acpi/nfit/mce.c +++ b/drivers/acpi/nfit/mce.c @@ -15,7 +15,7 @@ static int nfit_handle_mce(struct notifier_block *nb, uns= igned long val, { struct mce *mce =3D (struct mce *)data; struct acpi_nfit_desc *acpi_desc; - struct nfit_spa *nfit_spa; + struct nfit_spa *nfit_spa =3D NULL, *iter; =20 /* We only care about uncorrectable memory errors */ if (!mce_is_memory_error(mce) || mce_is_correctable(mce)) @@ -33,11 +33,10 @@ static int nfit_handle_mce(struct notifier_block *nb, u= nsigned long val, mutex_lock(&acpi_desc_lock); list_for_each_entry(acpi_desc, &acpi_descs, list) { struct device *dev =3D acpi_desc->dev; - int found_match =3D 0; =20 mutex_lock(&acpi_desc->init_mutex); - list_for_each_entry(nfit_spa, &acpi_desc->spas, list) { - struct acpi_nfit_system_address *spa =3D nfit_spa->spa; + list_for_each_entry(iter, &acpi_desc->spas, list) { + struct acpi_nfit_system_address *spa =3D iter->spa; =20 if (nfit_spa_type(spa) !=3D NFIT_SPA_PM) continue; @@ -46,7 +45,7 @@ static int nfit_handle_mce(struct notifier_block *nb, uns= igned long val, continue; if ((spa->address + spa->length - 1) < mce->addr) continue; - found_match =3D 1; + nfit_spa =3D iter; dev_dbg(dev, "addr in SPA %d (0x%llx, 0x%llx)\n", spa->range_index, spa->address, spa->length); /* @@ -58,7 +57,7 @@ static int nfit_handle_mce(struct notifier_block *nb, uns= igned long val, } mutex_unlock(&acpi_desc->init_mutex); =20 - if (!found_match) + if (!nfit_spa) continue; =20 /* If this fails due to an -ENOMEM, there is little we can do */ diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/= iomap.c index b752ce47ead3..5d3d6b0fce2e 100644 --- a/tools/testing/nvdimm/test/iomap.c +++ b/tools/testing/nvdimm/test/iomap.c @@ -227,8 +227,8 @@ static bool nfit_test_release_region(struct device *dev, struct nfit_test_resource *nfit_res =3D get_nfit_res(start); =20 if (nfit_res) { - struct nfit_test_request *req; - struct resource *res =3D NULL; + struct nfit_test_request *req =3D NULL; + struct nfit_test_request *iter; =20 if (dev) { devres_release(dev, nfit_devres_release, match, @@ -237,18 +237,18 @@ static bool nfit_test_release_region(struct device *d= ev, } =20 spin_lock(&nfit_res->lock); - list_for_each_entry(req, &nfit_res->requests, list) - if (req->res.start =3D=3D start) { - res =3D &req->res; - list_del(&req->list); + list_for_each_entry(iter, &nfit_res->requests, list) + if (iter->res.start =3D=3D start) { + list_del(&iter->list); + req =3D iter; break; } spin_unlock(&nfit_res->lock); =20 - WARN(!res || resource_size(res) !=3D n, + WARN(!req || resource_size(&req->res) !=3D n, "%s: start: %llx n: %llx mismatch: %pr\n", - __func__, start, n, res); - if (res) + __func__, start, n, &req->res); + if (req) kfree(req); return true; } base-commit: f443e374ae131c168a065ea1748feac6b2e76613 --=20 2.25.1