From patchwork Tue May 25 11:35:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 447178 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp4182445jac; Tue, 25 May 2021 04:35:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGgk8rJ8BeAs07RmKoR0AyuSRApTQ0iaS56QR+PrJiEYN7ZGEFynBRqknfCIrdsxI2bs9W X-Received: by 2002:a17:906:73d7:: with SMTP id n23mr28260882ejl.135.1621942543074; Tue, 25 May 2021 04:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621942543; cv=none; d=google.com; s=arc-20160816; b=vSmsEvboae12Q0xWlezPGAesR9/GOWdAxOMUf+6J/NN9jcpRDsIfIa21K33iFXV772 tde+yRO8YInmnDIMejQ2VbedltKVSTnjAMGIMQ7VOGrJNtHFmIG2oeyquzwmDtrC8eFR RATScvuTE7c0yBXFDZHJ8BtebSFXhr7aPRMThc1Z67pGIKyAaQVc5jKBkTw9nMP5Hha2 2C6w+wCWslFvzMmLamw0YpyFPd3weSVdyjjAFfU+1snEnxQN/Q+xsLkU70bZfpPdxl3B /liTBHmKROzr/4ZBuAOsa9Cba1+pyVbEm1CwUPVqUjBvSXNpMv/2koZqqnMHMLwzcvKS LVvg== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=bRNXfYSH+5Odn2Qi6ZCt89E7mAJjrUtW9JQJExI6MuU=; b=BMLWZnCbRgZ8yx4EYET2IQ4In6viF1yJi5TXQI9jSbZ4SymlSjcsF+oOvo0znTiNxB eyy2wjoYi1OaESEvK6sIY+S7yJBHtrWgtQ8NOp83c+0mYEbhx3iQ0QAKYZvuDp7/FUPE EfhNs+G5ggBgDxd80p41zdLq2hEeyGIn5xNrXFpJ4Cetj/KTy4hstXdk7g/J7sqKY8Kt NSxagy5gE/Y0/ZmNNXkBxs00eTz9atqADkedA9WctquMGFsthvWXIHcujfpTsV23Ufoa clFsJH8heVfZMwR8/hpXo5XpeRXErODmT5Aax1Axbha1LN1VWTwalBrkHeMEcT0HJtA7 /+CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WWnpGHWR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id p1si5251017edw.127.2021.05.25.04.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 04:35:43 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WWnpGHWR; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (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 33BCD82AE1; Tue, 25 May 2021 13:35:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WWnpGHWR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C538B82E66; Tue, 25 May 2021 13:35:38 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B257C82AB1 for ; Tue, 25 May 2021 13:35:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-wm1-x333.google.com with SMTP id z19-20020a7bc7d30000b029017521c1fb75so3238560wmk.0 for ; Tue, 25 May 2021 04:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bRNXfYSH+5Odn2Qi6ZCt89E7mAJjrUtW9JQJExI6MuU=; b=WWnpGHWRJAgxA9zIqweWvRmf5OK5kHcfRavvQybTPz4m1odT82aZ1Ds+95GAdvhWo8 onQ/DTJWnEdv3zL5IGaBQvaZIY6CrUkVokCkaX4lzMnQuOd/xLMHQCjnQyPLnlfXxQif KzfuHYN18mYs+cfcDvAvvdkqbAOVWkTaEsRe1PhrIbKeQ2/1A6VL+JXX4E3dNtMXR+YF PVhPeISO5eAnOk6TN/ThZuhS3RZM0CsL15S6F4t4iajwCle8ZJCFtSorGBtvK5YeqZJo 2x5em4HcXlzbz1IUDNPdmw95Vva3ysnyyf7I9jgjNpBQ8EKvNTVUefiCwDfspJ66sy/S 6Xmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=bRNXfYSH+5Odn2Qi6ZCt89E7mAJjrUtW9JQJExI6MuU=; b=fKyV1AKb/ulclQhagTK+nDR3+efv6ZENJGA9ziX72QcNOGr0i1iS/vp+dQKRD7UThn eqZoYXy2V+VaJv8CqoLzgXLvRojq10McHYDUQV8frWFkWl8pA7xwYucV5jiWKW8qdx+n ddIaLj4ZasMxSgva6kqPzXMmiBCL5WumrDo1eC2E/6EVLzsmd7n0imKkosqkJ9Q8iJ6I SJzuGQaKpi4qqQSwCJp2+JGUM3yx975cW55SDGBZF2Nn1u/a+ASefgGFsSgv8Fv2RotA vbnPluJX24dhVuInVEjJBez6VdK7ELR2uxKUg03+IsW4APsJ6FPGH8UtjdOjYrqEfsLH xxng== X-Gm-Message-State: AOAM532oVoc1OkAhFcMJZvzChngv3LgjvUzvLJPNXcUuIyDA8kkT2lB3 3KjONq1LLjhuzthcPxduVikexA== X-Received: by 2002:a05:600c:4f0b:: with SMTP id l11mr3378962wmq.126.1621942535266; Tue, 25 May 2021 04:35:35 -0700 (PDT) Received: from apalos.home ([2a02:587:466e:1389:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id v10sm18601617wrq.0.2021.05.25.04.35.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 04:35:34 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de, masahisa.kojima@linaro.org Cc: Ilias Apalodimas , Alexander Graf , u-boot@lists.denx.de Subject: [PATCH] efi_loader: Fix -Wextra warning for EFI TCG2 Date: Tue, 25 May 2021 14:35:31 +0300 Message-Id: <20210525113531.354963-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean Compiling with -Wextra produces a number of (harmless) warnings for the EFI TCG2 protocol. Let's fix those in case we ever enable the flag on the EFI subsystem Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_tcg2.c | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) -- 2.31.1 diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 39ef250bf9c4..39074f754772 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -53,7 +53,7 @@ struct digest_info { u16 hash_len; }; -const static struct digest_info hash_algo_list[] = { +static const struct digest_info hash_algo_list[] = { { TPM2_ALG_SHA1, EFI_TCG2_BOOT_HASH_ALG_SHA1, @@ -87,7 +87,7 @@ const static struct digest_info hash_algo_list[] = { */ static u32 alg_to_mask(u16 hash_alg) { - int i; + size_t i; for (i = 0; i < MAX_HASH_COUNT; i++) { if (hash_algo_list[i].hash_alg == hash_alg) @@ -106,7 +106,7 @@ static u32 alg_to_mask(u16 hash_alg) */ static u16 alg_to_len(u16 hash_alg) { - int i; + size_t i; for (i = 0; i < MAX_HASH_COUNT; i++) { if (hash_algo_list[i].hash_alg == hash_alg) @@ -119,7 +119,7 @@ static u16 alg_to_len(u16 hash_alg) static u32 tcg_event_final_size(struct tpml_digest_values *digest_list) { u32 len; - int i; + size_t i; len = offsetof(struct tcg_pcr_event2, digests); len += offsetof(struct tpml_digest_values, digests); @@ -145,7 +145,7 @@ static efi_status_t tcg2_pcr_extend(struct udevice *dev, u32 pcr_index, struct tpml_digest_values *digest_list) { u32 rc; - int i; + size_t i; for (i = 0; i < digest_list->count; i++) { u32 alg = digest_list->digests[i].hash_alg; @@ -178,7 +178,7 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, { void *log = (void *)((uintptr_t)event_log.buffer + event_log.pos); size_t pos; - int i; + size_t i; u32 event_size; if (event_log.get_event_called) @@ -400,7 +400,8 @@ static int tpm2_get_pcr_info(struct udevice *dev, u32 *supported_pcr, u8 response[TPM2_RESPONSE_BUFFER_SIZE]; struct tpml_pcr_selection pcrs; u32 ret, num_pcr; - int i, tpm_ret; + size_t i; + int tpm_ret; memset(response, 0, sizeof(response)); ret = tpm2_get_capability(dev, TPM2_CAP_PCRS, 0, response, 1); @@ -518,7 +519,7 @@ static efi_status_t tcg2_create_digest(const u8 *input, u32 length, u8 final[TPM2_SHA512_DIGEST_SIZE]; efi_status_t ret; u32 active; - int i; + size_t i; ret = __get_active_pcr_banks(&active); if (ret != EFI_SUCCESS) @@ -749,8 +750,7 @@ efi_tcg2_hash_log_extend_event(struct efi_tcg2_protocol *this, u64 flags, goto out; } - if (efi_tcg_event->header.pcr_index < 0 || - efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) { + if (efi_tcg_event->header.pcr_index > TPM2_MAX_PCRS) { ret = EFI_INVALID_PARAMETER; goto out; } @@ -810,9 +810,11 @@ out: * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_submit_command(struct efi_tcg2_protocol *this, - u32 input_param_block_size, u8 *input_param_block, - u32 output_param_block_size, u8 *output_param_block) +efi_tcg2_submit_command(__maybe_unused struct efi_tcg2_protocol *this, + u32 __maybe_unused input_param_block_size, + u8 __maybe_unused *input_param_block, + u32 __maybe_unused output_param_block_size, + u8 __maybe_unused *output_param_block) { return EFI_UNSUPPORTED; } @@ -847,8 +849,8 @@ efi_tcg2_get_active_pcr_banks(struct efi_tcg2_protocol *this, * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_set_active_pcr_banks(struct efi_tcg2_protocol *this, - u32 active_pcr_banks) +efi_tcg2_set_active_pcr_banks(__maybe_unused struct efi_tcg2_protocol *this, + u32 __maybe_unused active_pcr_banks) { return EFI_UNSUPPORTED; } @@ -866,8 +868,9 @@ efi_tcg2_set_active_pcr_banks(struct efi_tcg2_protocol *this, * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_get_result_of_set_active_pcr_banks(struct efi_tcg2_protocol *this, - u32 *operation_present, u32 *response) +efi_tcg2_get_result_of_set_active_pcr_banks(__maybe_unused struct efi_tcg2_protocol *this, + u32 __maybe_unused *operation_present, + u32 __maybe_unused *response) { return EFI_UNSUPPORTED; } @@ -898,7 +901,8 @@ static efi_status_t create_specid_event(struct udevice *dev, void *buffer, size_t spec_event_size; efi_status_t ret = EFI_DEVICE_ERROR; u32 active, supported; - int err, i; + int err; + size_t i; /* * Create Spec event. This needs to be the first event in the log