Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3503387pxb; Mon, 4 Apr 2022 19:04:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFbk8FpaNEa4IbMe4n0E3L8eo6Wj41GYYKrCgrpk1Yi7UD860p08IERMiojTPdMMHL+K6i X-Received: by 2002:a65:694e:0:b0:399:5aa8:2845 with SMTP id w14-20020a65694e000000b003995aa82845mr951776pgq.38.1649124294655; Mon, 04 Apr 2022 19:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649124294; cv=none; d=google.com; s=arc-20160816; b=Qt2ZX4IxBylybQsKQulhu0USMFj6O+8LIwRSPw79rvIk//od3psJ4fT542rWpV2rjm zqDle1k3ytBrC8TIk6dFEqY121Q+f0wHO4o5Z3gdoYNaWlNGHnZzAncha9g1MP05U9kN QiKNWAx4ceqadAkw2xNe5whHRavfxb3nSSYRF0CNeX6bOlX04XE1tQq5yAOnDC5e7UNQ e3AShZMEtGEgKXwVzsmmp4Qoolt7Y1ef/vNp7pgcUoSWRRrRMWjLcjtZrYaY9HAefcVp GUFcxl+21TUSKUTeSXQfX5KM5IPrW3O/mZ2iiuqOKs4+lovvccKB2k4PRqpSkv69PKFP T+bQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rSHqaeCwi2QD3QGRa2HT7kH4AFnUyMZ52I3NV95q5GM=; b=f9BcWd4KMeMeUnS0HilesWwsadiQNw0ntogWhM3/+zKWEX1gPxN1oz6WghAcLzivD2 s6qOAZ0DydbywsKwXC/Si2vvt7Mf4HbhWaxw3iRQ+v/ud/Xyamr/349m7bEjR7L9E2ui TvQ24tXMkc2phob7rPfei0mlUjf6ke9VJ5eL+3TzAxAOs3i2K55hddzIObw1DQC0+vUo JMFQbuSwRNn5csWmcVbuyygD2KBPFTIJkkW7ReooZiBAcYE+bcGKWo+AMJOGPiaW9Q3f wY0ptC2ACxmDpGWji4C08Z92qtOVJZcew/lVrDsEnzjXqOP178JwMl9O32nxq6CPZaMY kLVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Pan4DsKz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i16-20020a17090332d000b001569a746663si6275306plr.511.2022.04.04.19.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:04:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Pan4DsKz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 27777220FD6; Mon, 4 Apr 2022 17:28:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242300AbiCaWNa (ORCPT + 99 others); Thu, 31 Mar 2022 18:13:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242294AbiCaWN2 (ORCPT ); Thu, 31 Mar 2022 18:13:28 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 611A32467D5; Thu, 31 Mar 2022 15:11:40 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id dr20so2108365ejc.6; Thu, 31 Mar 2022 15:11:40 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=rSHqaeCwi2QD3QGRa2HT7kH4AFnUyMZ52I3NV95q5GM=; b=Pan4DsKz/3eGh99T01l3+pjIWjhQWcMXgqhP6g3wWts1Nc3tuD/v8nE9cIUShX+1+6 N/uT3WyhLdhLZgH7p1Pmpp7rn/jgGyhrMzyPT7FomwdA68v5BrmFhiFhngsP0zuxLk19 EblbpXz3Mb5bfjrFqtCdvFNawCYr5KizCrMMS3hgv0WApHIRzMTyao8DS6ByGRnz7adF Ijlmoivly5IS86Mrg9+YuixMXgwVSq9t8x76CtIBcf5iH8bMmuXRN/Igzua63es8gYG0 F3J+KX0GoAKD5VFYOCaX6YYnjj63XR5AsJemXHpmRPaozh18Sr+D232fxWKoQx2ofHni tKKA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=rSHqaeCwi2QD3QGRa2HT7kH4AFnUyMZ52I3NV95q5GM=; b=XwssCdNT02qwbQJr0A46qrddAbJ5hJPs8tVhkBsJFfx31+PQwGLxJvHymrmLRCAeZK K81Pi/9/+xvx3qPqSkZKJpApSktq+6UaYm2SvwyTdKrzLaF1/1BqoC6cSx57LoqBDEoj bVLeJaQq7STa4c/5pybztgOVrlUuDYR+cve23ZpIoN/S19GYVsFZzP7My9FXKqtaTM+0 WE1JFDe2TZK3oimDFzI0QCoTo4svLb040sdc3V34EKNr6ZQPXPaHp4s2lGDzn5zq2MGH Mnrnunsg80rYpufiCM3f35Lk4uSd1/1QwVh0es4HDgtqw0q8W9dLUO0bzlv/pq0ZAmp0 fXFw== X-Gm-Message-State: AOAM531/UekHJAYii0el7Ebqd9ll+54xiHTlMbESeuzFzIXxZRRvZf8H bDtZYMbrv1MIdY3YfYA195M8tVe7TfS8Cg== X-Received: by 2002:a17:906:3ec7:b0:6d6:e52b:b with SMTP id d7-20020a1709063ec700b006d6e52b000bmr6931528ejj.521.1648764698980; Thu, 31 Mar 2022 15:11:38 -0700 (PDT) Received: from localhost.localdomain (i130160.upc-i.chello.nl. [62.195.130.160]) by smtp.googlemail.com with ESMTPSA id z6-20020a056402274600b004194fc1b7casm321322edd.48.2022.03.31.15.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Mar 2022 15:11:38 -0700 (PDT) From: Jakob Koschel To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Mike Rapoport , "Brian Johannesmeyer" , Cristiano Giuffrida , "Bos, H.J." , Jakob Koschel Subject: [PATCH 2/2] efi: replace usage of found with dedicated list iterator variable Date: Fri, 1 Apr 2022 00:10:30 +0200 Message-Id: <20220331221030.889718-2-jakobkoschel@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220331221030.889718-1-jakobkoschel@gmail.com> References: <20220331221030.889718-1-jakobkoschel@gmail.com> 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/firmware/efi/vars.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c index 3994aad38661..e4e1cc593441 100644 --- a/drivers/firmware/efi/vars.c +++ b/drivers/firmware/efi/vars.c @@ -809,22 +809,21 @@ EXPORT_SYMBOL_GPL(efivar_entry_set_safe); struct efivar_entry *efivar_entry_find(efi_char16_t *name, efi_guid_t guid, struct list_head *head, bool remove) { - struct efivar_entry *entry, *n; + struct efivar_entry *entry = NULL, *iter, *n; int strsize1, strsize2; - bool found = false; - list_for_each_entry_safe(entry, n, head, list) { + list_for_each_entry_safe(iter, n, head, list) { strsize1 = ucs2_strsize(name, 1024); - strsize2 = ucs2_strsize(entry->var.VariableName, 1024); + strsize2 = ucs2_strsize(iter->var.VariableName, 1024); if (strsize1 == strsize2 && - !memcmp(name, &(entry->var.VariableName), strsize1) && - !efi_guidcmp(guid, entry->var.VendorGuid)) { - found = true; + !memcmp(name, &(iter->var.VariableName), strsize1) && + !efi_guidcmp(guid, iter->var.VendorGuid)) { + entry = iter; break; } } - if (!found) + if (!entry) return NULL; if (remove) { -- 2.25.1