From nobody Sat Jun 20 01:53:40 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 AA588C4332F for ; Thu, 24 Mar 2022 07:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348627AbiCXHeS (ORCPT ); Thu, 24 Mar 2022 03:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348694AbiCXHdv (ORCPT ); Thu, 24 Mar 2022 03:33:51 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A5399EC1 for ; Thu, 24 Mar 2022 00:32:17 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id yy13so7371486ejb.2 for ; Thu, 24 Mar 2022 00:32:17 -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=cwARqHfBcNG+A/ztBylRd5QKvLrPJk1MiaHSLHQF1Mw=; b=ouWHYKVwLTHfz+/RTaOKfR2owtH6GWGi6MOzNaazzvVoauGpw/6LkQjgoV5lGO7Vp3 NZRorMZw8KXNfDPE81jkkUxJ7wsgW66fQ0+a9VLB2xgo5CErrcINwiqSRtXek7IsnFfM GSSqzBvbTOccq1hu9aUMCk5MQW7/TAQKelB2VBrvlbhUB24vhN7/xbm1IDkN88eqVPcp ZyrFLsucC0bMib9ptb1hZxMRtdPjqzWTxQRheutxQQhOL3zrT+x+fdpfLMqUyu6XQ3Kg HuW5NXgRmOyihg9HGFa9HGf1siZGSACS9hLJm+5+Y1oRMqnpL+/twD6uKOscehW3Tp+g Sq7A== 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=cwARqHfBcNG+A/ztBylRd5QKvLrPJk1MiaHSLHQF1Mw=; b=dC5r7zdCIf+S4lcxlAs2Lol3uymSQLwmvIZMO43L6/v3I7OyqopzuzHVneNfwwDuJV Gbg4BsXNRZErVmv/+2xLWF3HxLZhbvoO3BosyT+YwspUdeEGk/nLcBXQe/TU1qH/38iz b+CtizHlsJQWNdwav1lcNo9cSLWN8r3tTwsMy8zEIeMp70YHrc2CzeNlfCP7UB58OW57 DVtS20J6Z9/oukBfiZuvKfrGmKx2ASFEDymcHDXSImADLTx2S660ecq+jsrfwRlQG5oK 6lbYDORE97PTzL31yUhsICe9sbC9x/8amCTC55hjzDCRRynyi15D8iW2Vi6XglqkdBcy iD0g== X-Gm-Message-State: AOAM533Js7Q6NJHUPMTZ2xeP/YzR9k8w7sUhKv7qI3Zz6hSrA/TRZC79 MbY42QNv8yX6iZM1u4cUWqGBcpXJAXpxDskx X-Google-Smtp-Source: ABdhPJxi8ZhUXWjM2W5iRG079QUt1B59geQlxGFjwNM9YfUhNuKa2fOk4OL3NZ38Q3mDIO7Dtu66XA== X-Received: by 2002:a17:907:6d11:b0:6df:f38b:b698 with SMTP id sa17-20020a1709076d1100b006dff38bb698mr4268310ejc.711.1648107136033; Thu, 24 Mar 2022 00:32:16 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id m17-20020a17090672d100b006df98bb199dsm773047ejl.129.2022.03.24.00.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 00:32:15 -0700 (PDT) From: Jakob Koschel To: Jorgen Hansen Cc: Vishnu Dasa , VMware PV-Drivers Reviewers , Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH] misc: vmw_vmci: replace usage of found with dedicated list iterator variable Date: Thu, 24 Mar 2022 08:31:51 +0100 Message-Id: <20220324073151.66305-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/misc/vmw_vmci/vmci_context.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/misc/vmw_vmci/vmci_context.c b/drivers/misc/vmw_vmci/v= mci_context.c index 6cf3e21c7604..172696abce31 100644 --- a/drivers/misc/vmw_vmci/vmci_context.c +++ b/drivers/misc/vmw_vmci/vmci_context.c @@ -665,9 +665,8 @@ int vmci_ctx_add_notification(u32 context_id, u32 remot= e_cid) int vmci_ctx_remove_notification(u32 context_id, u32 remote_cid) { struct vmci_ctx *context; - struct vmci_handle_list *notifier, *tmp; + struct vmci_handle_list *notifier =3D NULL, *iter, *tmp; struct vmci_handle handle; - bool found =3D false; =20 context =3D vmci_ctx_get(context_id); if (!context) @@ -676,23 +675,23 @@ int vmci_ctx_remove_notification(u32 context_id, u32 = remote_cid) handle =3D vmci_make_handle(remote_cid, VMCI_EVENT_HANDLER); =20 spin_lock(&context->lock); - list_for_each_entry_safe(notifier, tmp, + list_for_each_entry_safe(iter, tmp, &context->notifier_list, node) { - if (vmci_handle_is_equal(notifier->handle, handle)) { - list_del_rcu(¬ifier->node); + if (vmci_handle_is_equal(iter->handle, handle)) { + list_del_rcu(&iter->node); context->n_notifiers--; - found =3D true; + notifier =3D iter; break; } } spin_unlock(&context->lock); =20 - if (found) + if (notifier) kvfree_rcu(notifier); =20 vmci_ctx_put(context); =20 - return found ? VMCI_SUCCESS : VMCI_ERROR_NOT_FOUND; + return notifier ? VMCI_SUCCESS : VMCI_ERROR_NOT_FOUND; } =20 static int vmci_ctx_get_chkpt_notifiers(struct vmci_ctx *context, base-commit: f443e374ae131c168a065ea1748feac6b2e76613 --=20 2.25.1