From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8320C433EF for ; Tue, 5 Oct 2021 18:25:12 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6D2061166 for ; Tue, 5 Oct 2021 18:25:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6D2061166 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 28CE882D78; Tue, 5 Oct 2021 20:25:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="T6gM1Sbz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 04F2D82DA1; Tue, 5 Oct 2021 20:25:07 +0200 (CEST) Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (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 9E1D382D1C for ; Tue, 5 Oct 2021 20:25:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x32b.google.com with SMTP id 97-20020a9d006a000000b00545420bff9eso27040950ota.8 for ; Tue, 05 Oct 2021 11:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=J2Toegd5Q66lulStUsLRkEPM409if5p9yT+woWPprWA=; b=T6gM1SbzDWgbnDajmfCr7l+ZJPAlHZgW+OXEXpd1zFRT14WdpGymZ50eePgtxBmn0/ D5baMHcNyfh/xBaNrGHjVLBZEq8wxrzTlRyzVABpB67X9GW3YnUnu59wN+pxWUZpDw60 QURVSjhTDgV3CAF/B11yc8mVS3jlV6y0Z2Y6MWMemKyDVdytkF23zYF89sejfw/CQtTA Ctjv8yyK/rYbScc7lswXyWL3jI+3a3T5eyo+dYh2f7iMeplkLWpJGf8ZR4uwUDgYKOYP 33cJTzA4BtsV2a9BKJ0frZBpONFK5rtcxff7chnFtosjrl7B+RfHdWz+5f1XBNmo+xiJ uTJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=J2Toegd5Q66lulStUsLRkEPM409if5p9yT+woWPprWA=; b=p+OofvRXldmVdn+dOP65RfnQg9WBUxFjSU6meFLIzxT5oC8MeNa+h22KOwKe5g1+3o oDvvStcJcDgMdXi9sEYiq+qfbSteGVzTWWinVRIDVG3VwKxBEoMk2qe55gwbtWFq5lsm 4bwuP9wudiXuAhQEV54ZG50M4Tz5djB4Lvs9Et9eJPCefhVCkVJS7i35gIAT0qfe+X3x yNfRoeP1Zf4X4sYxGNGIrzh8U0dvjki7f7cxLavgFoFQa+qGble22yhvwVXkJNnITEcF wnFI1LukHs4p4X8YdDBVozUzodflwLpIbdvXxXSQClUUysTJwbjgVqFfAgqskQADfSmf faJA== X-Gm-Message-State: AOAM533KIg1w+z+ZtdsP0aPLYxAndm5LqZb+Z/8MMj1guoQawXanIgfS RxMXfUJTlNf1jT4/bQZKMSU= X-Google-Smtp-Source: ABdhPJxaRa+Xr/Q87XyHQTUZd4CKUq1aB+f0M2rwN0D+qZCI6xoEhnKkHP9nnyVIrG6RO4RZjLcQDA== X-Received: by 2002:a9d:4705:: with SMTP id a5mr15396206otf.237.1633458301363; Tue, 05 Oct 2021 11:25:01 -0700 (PDT) Received: from nuclearis3.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id e2sm3506963ooh.40.2021.10.05.11.25.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 11:25:00 -0700 (PDT) Subject: Re: [PATCH v5 06/29] hash: Drop some #ifdefs in hash.c To: Simon Glass , U-Boot Mailing List Cc: Andre Przywara , Rasmus Villemoes , Robert Marko , Masahiro Yamada , Tom Rini , Joe Hershberger References: <20210926014342.127913-1-sjg@chromium.org> <20210926014342.127913-5-sjg@chromium.org> From: "Alex G." Message-ID: <460af1dd-9d9a-c8e9-2a39-fffcfbee1a03@gmail.com> Date: Tue, 5 Oct 2021 13:24:59 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210926014342.127913-5-sjg@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean On 9/25/21 8:43 PM, Simon Glass wrote: > We can use the __maybe_unused attribute to avoid some of the #ifdefs in > this file. Update the functions accordingly. > > Note: The actual hashing interface is still a mess, with four separate > combinations and lots of #ifdefs. This should really use a driver > approach, e.g. as is done with partition drivers. > > Signed-off-by: Simon Glass > --- > I'm not too excited about a qualifier that maybe tells me something about the function. Assuming we move these to linker lists in the near (not far) future, Reviewed-by: Alexandru Gagniuc > Changes in v5: > - Rebase to next > > common/hash.c | 54 ++++++++++++++++++++++++--------------------------- > 1 file changed, 25 insertions(+), 29 deletions(-) > > diff --git a/common/hash.c b/common/hash.c > index 0fe65c959d0..e92f9a9594f 100644 > --- a/common/hash.c > +++ b/common/hash.c > @@ -24,6 +24,7 @@ > #include > #else > #include "mkimage.h" > +#include > #include > #include > #endif /* !USE_HOSTCC*/ > @@ -42,8 +43,7 @@ DECLARE_GLOBAL_DATA_PTR; > > static void reloc_update(void); > > -#if CONFIG_IS_ENABLED(SHA1) && !CONFIG_IS_ENABLED(SHA_PROG_HW_ACCEL) > -static int hash_init_sha1(struct hash_algo *algo, void **ctxp) > +static int __maybe_unused hash_init_sha1(struct hash_algo *algo, void **ctxp) > { > sha1_context *ctx = malloc(sizeof(sha1_context)); > sha1_starts(ctx); > @@ -51,15 +51,16 @@ static int hash_init_sha1(struct hash_algo *algo, void **ctxp) > return 0; > } > > -static int hash_update_sha1(struct hash_algo *algo, void *ctx, const void *buf, > - unsigned int size, int is_last) > +static int __maybe_unused hash_update_sha1(struct hash_algo *algo, void *ctx, > + const void *buf, unsigned int size, > + int is_last) > { > sha1_update((sha1_context *)ctx, buf, size); > return 0; > } > > -static int hash_finish_sha1(struct hash_algo *algo, void *ctx, void *dest_buf, > - int size) > +static int __maybe_unused hash_finish_sha1(struct hash_algo *algo, void *ctx, > + void *dest_buf, int size) > { > if (size < algo->digest_size) > return -1; > @@ -68,10 +69,8 @@ static int hash_finish_sha1(struct hash_algo *algo, void *ctx, void *dest_buf, > free(ctx); > return 0; > } > -#endif > > -#if CONFIG_IS_ENABLED(SHA256) && !CONFIG_IS_ENABLED(SHA_PROG_HW_ACCEL) > -static int hash_init_sha256(struct hash_algo *algo, void **ctxp) > +static int __maybe_unused hash_init_sha256(struct hash_algo *algo, void **ctxp) > { > sha256_context *ctx = malloc(sizeof(sha256_context)); > sha256_starts(ctx); > @@ -79,15 +78,16 @@ static int hash_init_sha256(struct hash_algo *algo, void **ctxp) > return 0; > } > > -static int hash_update_sha256(struct hash_algo *algo, void *ctx, > - const void *buf, unsigned int size, int is_last) > +static int __maybe_unused hash_update_sha256(struct hash_algo *algo, void *ctx, > + const void *buf, uint size, > + int is_last) > { > sha256_update((sha256_context *)ctx, buf, size); > return 0; > } > > -static int hash_finish_sha256(struct hash_algo *algo, void *ctx, void > - *dest_buf, int size) > +static int __maybe_unused hash_finish_sha256(struct hash_algo *algo, void *ctx, > + void *dest_buf, int size) > { > if (size < algo->digest_size) > return -1; > @@ -96,10 +96,8 @@ static int hash_finish_sha256(struct hash_algo *algo, void *ctx, void > free(ctx); > return 0; > } > -#endif > > -#if CONFIG_IS_ENABLED(SHA384) && !CONFIG_IS_ENABLED(SHA_PROG_HW_ACCEL) > -static int hash_init_sha384(struct hash_algo *algo, void **ctxp) > +static int __maybe_unused hash_init_sha384(struct hash_algo *algo, void **ctxp) > { > sha512_context *ctx = malloc(sizeof(sha512_context)); > sha384_starts(ctx); > @@ -107,15 +105,16 @@ static int hash_init_sha384(struct hash_algo *algo, void **ctxp) > return 0; > } > > -static int hash_update_sha384(struct hash_algo *algo, void *ctx, > - const void *buf, unsigned int size, int is_last) > +static int __maybe_unused hash_update_sha384(struct hash_algo *algo, void *ctx, > + const void *buf, uint size, > + int is_last) > { > sha384_update((sha512_context *)ctx, buf, size); > return 0; > } > > -static int hash_finish_sha384(struct hash_algo *algo, void *ctx, void > - *dest_buf, int size) > +static int __maybe_unused hash_finish_sha384(struct hash_algo *algo, void *ctx, > + void *dest_buf, int size) > { > if (size < algo->digest_size) > return -1; > @@ -124,10 +123,8 @@ static int hash_finish_sha384(struct hash_algo *algo, void *ctx, void > free(ctx); > return 0; > } > -#endif > > -#if CONFIG_IS_ENABLED(SHA512) && !CONFIG_IS_ENABLED(SHA_PROG_HW_ACCEL) > -static int hash_init_sha512(struct hash_algo *algo, void **ctxp) > +static int __maybe_unused hash_init_sha512(struct hash_algo *algo, void **ctxp) > { > sha512_context *ctx = malloc(sizeof(sha512_context)); > sha512_starts(ctx); > @@ -135,15 +132,16 @@ static int hash_init_sha512(struct hash_algo *algo, void **ctxp) > return 0; > } > > -static int hash_update_sha512(struct hash_algo *algo, void *ctx, > - const void *buf, unsigned int size, int is_last) > +static int __maybe_unused hash_update_sha512(struct hash_algo *algo, void *ctx, > + const void *buf, uint size, > + int is_last) > { > sha512_update((sha512_context *)ctx, buf, size); > return 0; > } > > -static int hash_finish_sha512(struct hash_algo *algo, void *ctx, void > - *dest_buf, int size) > +static int __maybe_unused hash_finish_sha512(struct hash_algo *algo, void *ctx, > + void *dest_buf, int size) > { > if (size < algo->digest_size) > return -1; > @@ -152,8 +150,6 @@ static int hash_finish_sha512(struct hash_algo *algo, void *ctx, void > free(ctx); > return 0; > } > -#endif > - > > static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp) > { >