Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp965164pxb; Thu, 24 Mar 2022 10:06:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgBOPNqDE4WF7vUODmBLQikdiKMr4jWt5WVQESUtBit/8aGs45ZOaIQB6xI1r0CRIQZUtO X-Received: by 2002:a05:6808:2023:b0:2da:5b6a:a526 with SMTP id q35-20020a056808202300b002da5b6aa526mr3322515oiw.264.1648141577714; Thu, 24 Mar 2022 10:06:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648141577; cv=none; d=google.com; s=arc-20160816; b=qpGR9bX4424RKqAv2CWdpf/MWk5gSG6iccpDJVt3p5qskAkcIbCQyr8aVmH9yDYCD7 DVqMo/LJ02xSMDIGla0jq4+VVD3bT9T3elM4B0CD5v+7hbQAMYrlyYPLYr0yG3InlJpg 8XMu0UqzaZNtlIGAdEsEH2pmFoEq4Y0q3pZPiGwT65U82GfkKEngq6juwFJeh6+5uAHJ GWt/fJvVWYAUKUszFJlVxh/GzVA0KDkCwxmFJ/arkEapbu4H6Nd9kCJYlTzlD/+PkDbj Vt8CG+MdBTFlgvN7//DPO8vQTtyHNJNQMa+efGPlJC0YO5rHHilGGri91UxxP27OGgNV dxBA== 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=QmJzxumpLQcs11vK+3c+4EgOpxANBX6MJwGXngCOMXo=; b=R1XAJvrgoKRT5oIutkN9h4ZuOGQ87bEAfJVYWQSKtxr9Qdb12zhmdltGUsE1z5Qzav +X7X8Ac4o/lYziVWPsO5tCOBTPj0I/VRAal/+me1C+ZjftxhfyeBB5K1kw0v2x0K7OuD exORsQuhnPblwjsXwqSjdSCaqr/61GjLootGPxRq12LKp9Eu/Ej2vaEGaSL6aho4tvoL XhT3WjKmt2pLLGuGYy0PkUSYs+HlsZP73khb6vnuvxPSzVVNjtsRp3jnPPcP4obueNaK F3c+d12PmPDr8MBbOgLvD344zdpsW6b/f3EVh0msRl8aY2czUc+uti/u2FUgxnqhlxVU 1DcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LL2eN8sS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j128-20020aca3c86000000b002ef0c347614si105271oia.148.2022.03.24.10.05.57; Thu, 24 Mar 2022 10:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LL2eN8sS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241471AbiCXHGZ (ORCPT + 99 others); Thu, 24 Mar 2022 03:06:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230024AbiCXHGY (ORCPT ); Thu, 24 Mar 2022 03:06:24 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C225E7DE23; Thu, 24 Mar 2022 00:04:52 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id u26so4470528eda.12; Thu, 24 Mar 2022 00:04:52 -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=QmJzxumpLQcs11vK+3c+4EgOpxANBX6MJwGXngCOMXo=; b=LL2eN8sSyTOZ859wDP3jr4bcEgBnKx5LwkENba4N6GLZYypfPt211FxmqWSDMQJHge TBqhuCw1rBMDXoSc/gzl5gOJ1TI1kDob/jdIsXZkyNYAz1UAsVpzcbn2UIeS8Yw6vncg Zp97G7vdkkt14jKJHjWur/+xxokAcjm2zQL0uJip4RCrPICFsRErLZ7DMGBB6ia+uHMm EYuObp7A3gzYScsUT8dfPLP/11gWH/60IMuyM9a+kJ4+di4B2jIEekA5G6fvVRSSyk0Q DZAHcILhTGzONIWvnQxHIbkKgmoK85UhJ6Z1hgi/0MWK9nQ/YQ+QUa4IArzulTJnhAow mwOQ== 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=QmJzxumpLQcs11vK+3c+4EgOpxANBX6MJwGXngCOMXo=; b=SLoPAfXFBu+pl+qVsWAo1kxeayrAcwg5oLfDW8KzeSv7eNul03TFD2YOZLu7l3CBrW +oDdAQgl/taNFePa9YCmHai1NYoqzLbhfc7YuxRnqjzRPpdJx/MekwP6q1lSF+YkRFLW 7OEtcVFPACXCZcZqAT30ZGK6ZCsHeXZ1f8HY/zz7qrVgsIQF0rxJMCui5Z5u16GVVPIj hOeIxN6+OZpd8GZXTM33eF/8nG97UJjjlXIsoljK2N0pUg11L5tMzB9/X6TZFY3Jlfmk mdOnSBrFr+lu+Iytftd7HJXs51okyaXAe/sc+GwgmTancAHyM9C3T7HM3kamnRcwAoTZ fC/w== X-Gm-Message-State: AOAM533ajCSGf2GuhhL8L9qsAK4RHyc5BG2xV07K+FYkGiWWs4wRXHsh D/c2iQL0+4vN41DnFPJ95mw= X-Received: by 2002:a50:fe0d:0:b0:415:e2ee:65af with SMTP id f13-20020a50fe0d000000b00415e2ee65afmr4811578edt.383.1648105491201; Thu, 24 Mar 2022 00:04:51 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id d24-20020a1709067a1800b006e021f4c1c3sm753022ejo.166.2022.03.24.00.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:04:50 -0700 (PDT) From: Jakob Koschel To: "Rafael J. Wysocki" Cc: Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] ACPI: ipmi: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:04:41 +0100 Message-Id: <20220324070441.56591-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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/acpi/acpi_ipmi.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/acpi/acpi_ipmi.c b/drivers/acpi/acpi_ipmi.c index a5fe2926bf50..0555f68c2dfd 100644 --- a/drivers/acpi/acpi_ipmi.c +++ b/drivers/acpi/acpi_ipmi.c @@ -353,29 +353,27 @@ static void ipmi_flush_tx_msg(struct acpi_ipmi_device *ipmi) static void ipmi_cancel_tx_msg(struct acpi_ipmi_device *ipmi, struct acpi_ipmi_msg *msg) { - struct acpi_ipmi_msg *tx_msg, *temp; - bool msg_found = false; + struct acpi_ipmi_msg *tx_msg = NULL, *iter, *temp; unsigned long flags; spin_lock_irqsave(&ipmi->tx_msg_lock, flags); - list_for_each_entry_safe(tx_msg, temp, &ipmi->tx_msg_list, head) { - if (msg == tx_msg) { - msg_found = true; - list_del(&tx_msg->head); + list_for_each_entry_safe(iter, temp, &ipmi->tx_msg_list, head) { + if (msg == iter) { + tx_msg = iter; + list_del(&iter->head); break; } } spin_unlock_irqrestore(&ipmi->tx_msg_lock, flags); - if (msg_found) + if (tx_msg) acpi_ipmi_msg_put(tx_msg); } static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) { struct acpi_ipmi_device *ipmi_device = user_msg_data; - bool msg_found = false; - struct acpi_ipmi_msg *tx_msg, *temp; + struct acpi_ipmi_msg *tx_msg = NULL, *iter, *temp; struct device *dev = ipmi_device->dev; unsigned long flags; @@ -387,16 +385,16 @@ static void ipmi_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) } spin_lock_irqsave(&ipmi_device->tx_msg_lock, flags); - list_for_each_entry_safe(tx_msg, temp, &ipmi_device->tx_msg_list, head) { - if (msg->msgid == tx_msg->tx_msgid) { - msg_found = true; - list_del(&tx_msg->head); + list_for_each_entry_safe(iter, temp, &ipmi_device->tx_msg_list, head) { + if (msg->msgid == iter->tx_msgid) { + tx_msg = iter; + list_del(&iter->head); break; } } spin_unlock_irqrestore(&ipmi_device->tx_msg_lock, flags); - if (!msg_found) { + if (!tx_msg) { dev_warn(dev, "Unexpected response (msg id %ld) is returned.\n", msg->msgid); @@ -482,15 +480,14 @@ static void ipmi_register_bmc(int iface, struct device *dev) static void ipmi_bmc_gone(int iface) { - struct acpi_ipmi_device *ipmi_device, *temp; - bool dev_found = false; + struct acpi_ipmi_device *ipmi_device = NULL, *iter, *temp; mutex_lock(&driver_data.ipmi_lock); - list_for_each_entry_safe(ipmi_device, temp, + list_for_each_entry_safe(iter, temp, &driver_data.ipmi_devices, head) { - if (ipmi_device->ipmi_ifnum != iface) { - dev_found = true; - __ipmi_dev_kill(ipmi_device); + if (iter->ipmi_ifnum != iface) { + ipmi_device = iter; + __ipmi_dev_kill(iter); break; } } @@ -500,7 +497,7 @@ static void ipmi_bmc_gone(int iface) struct acpi_ipmi_device, head); mutex_unlock(&driver_data.ipmi_lock); - if (dev_found) { + if (ipmi_device) { ipmi_flush_tx_msg(ipmi_device); acpi_ipmi_dev_put(ipmi_device); } base-commit: f443e374ae131c168a065ea1748feac6b2e76613 -- 2.25.1