From patchwork Tue Jul 30 11:11:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 815301 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp242765wrs; Tue, 30 Jul 2024 04:12:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXdCdHg4QlCqyJlasPXDHavWotP9iOKFqjyttCkAj7bTSX6fC/S04Rwy0G+Cn5V++SSZ5YEsM/tCaY/IwHNsL0c X-Google-Smtp-Source: AGHT+IHodk+KcTKjyBgYIeeF8kxzxIxEw2Q+xYPCXFbihuTdJrLYpHPxnW4QRQ8LyZBt0XnPKMcs X-Received: by 2002:a17:907:86a7:b0:a7a:a2e3:3739 with SMTP id a640c23a62f3a-a7d8595e547mr175745566b.20.1722337930172; Tue, 30 Jul 2024 04:12:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722337930; cv=none; d=google.com; s=arc-20160816; b=yd7UctWhe6DwjV3cpb0u2SOIdlqYgFxRpVVnVPX1E0V9I0KN0X/bJzNyBir7WlVvKm aHvgHapMIaBRxwOxjytozsqE0ItDbBODIXhbICO7PxoOOF8LLg0BQxagcnv8jvdAW+X+ tp51alxIdKTBAuT4399BjgnJPT/7BSYbG1izL3PSeaMw5yywAq7vePzBz/q9j6hnwSy+ BGd6a+q3lOTTNE1HfIVoZ2fiwoGQLArsJCV60vsRb+hDDPBH3sEoBH+iScAIsGGX1hOS PYdhNSRzIKUP3RtnD2Qztys8uUv/oU5sUBRAOanricIvDvSbJbX+WzrIZn1gUI2pT9cq A6AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=GVEt5U2ofd0uufSq0NLuIhDd3uNoV3soBMY7bT6CEcY=; fh=c60fu1IChZaOc2lQYQAOoRysAfBqXosZh6e58mdWpwk=; b=qoHVuiiJ//Ss4YfZJ/60Yrz8CgZHyMfan92Of6aMOtirw4SB8bjy82e69R5va4DIAf uJj4uIBvuu2VqpEcqFhSDB9NzG9flIOLyzOSRbu5ZFGJ7PYMXJnphB0Zdksm8oU8dqt2 UcIMLTMdbvYWWI6hp7CGfRtn7rYsT+8m9WiUjG+CgffgnLG8dh2YZMpc06t+WtITTwke XVKWqQAJ+VX6Mt2JQldixm5L4jZLQk6mIeMW9xeDQVj6X/x4l1G0/yyu55hF5yXNpOli r/x4vascBQThYuRIDtxROZTHpVwNCk9yVtB6DfRW5Rw1OYXgQzbbFH+/nYUT8juMpRSA eS+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id a640c23a62f3a-a7acab3d01dsi746340266b.470.2024.07.30.04.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 04:12:10 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3D6ED887E4; Tue, 30 Jul 2024 13:12:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id A1E50887BF; Tue, 30 Jul 2024 13:11:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id B4C9987A55 for ; Tue, 30 Jul 2024 13:11:57 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C622B1007; Tue, 30 Jul 2024 04:12:22 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7CF983F5A1; Tue, 30 Jul 2024 04:11:55 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Sughosh Ganu Subject: [PATCH 2/5] efi_memory: use list_count_nodes() to count list entries Date: Tue, 30 Jul 2024 16:41:29 +0530 Message-Id: <20240730111132.1097315-2-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730111132.1097315-1-sughosh.ganu@linaro.org> References: <20240730111132.1097315-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Use the API function list_count_nodes() to count the number of EFI memory map entries. Signed-off-by: Sughosh Ganu Reviewed-by: Simon Glass --- lib/efi_loader/efi_memory.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 12cf23fa3f..bfadd6bd41 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -742,8 +742,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, efi_uintn_t *descriptor_size, uint32_t *descriptor_version) { + int map_entries; efi_uintn_t map_size = 0; - int map_entries = 0; struct list_head *lhandle; efi_uintn_t provided_map_size; @@ -752,8 +752,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, provided_map_size = *memory_map_size; - list_for_each(lhandle, &efi_mem) - map_entries++; + map_entries = list_count_nodes(&efi_mem); map_size = map_entries * sizeof(struct efi_mem_desc);