All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alex G." <mr.nuke.me@gmail.com>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>,
	Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>, Donald Chan <hoiho@lab126.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	u-boot@lists.denx.de
Subject: Re: [PATCH] lib/rsa: avoid -Wdiscarded-qualifiers
Date: Mon, 10 Jan 2022 09:00:29 -0600	[thread overview]
Message-ID: <61f8f122-59cb-686d-440f-250aa428dfc9@gmail.com> (raw)
In-Reply-To: <20220109143940.167046-1-heinrich.schuchardt@canonical.com>



On 1/9/22 8:39 AM, Heinrich Schuchardt wrote:
> The return type of EVP_PKEY_get0_RSA() is const struct rsa_st *.
> Our code drops the const qualifier leading to
> 
> In file included from tools/lib/rsa/rsa-sign.c:1:
> ./tools/../lib/rsa/rsa-sign.c: In function ‘rsa_add_verify_data’:
> ./tools/../lib/rsa/rsa-sign.c:631:13: warning:
> assignment discards ‘const’ qualifier from pointer target type
> [-Wdiscarded-qualifiers]
>    631 |         rsa = EVP_PKEY_get0_RSA(pkey);
>        |             ^
> 
> Add a type conversion.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
>   lib/rsa/rsa-sign.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c
> index 44f21416ce..3b6e5f0f86 100644
> --- a/lib/rsa/rsa-sign.c
> +++ b/lib/rsa/rsa-sign.c
> @@ -628,7 +628,7 @@ int rsa_add_verify_data(struct image_sign_info *info, void *keydest)
>   	if (ret)
>   		goto err_get_pub_key;
>   
> -	rsa = EVP_PKEY_get0_RSA(pkey);
> +	rsa = (RSA *)EVP_PKEY_get0_RSA(pkey);

I think it's the wrong path to discard const qualifiers, whether 
unwillingly or by type punning. I suggest making 'rsa' a "const RSA *" 
and fixing the downstream users to do the same.

Alex

>   	ret = rsa_get_params(rsa, &exponent, &n0_inv, &modulus, &r_squared);
>   	if (ret)
>   		goto err_get_params;
> 

  reply	other threads:[~2022-01-10 15:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 14:39 [PATCH] lib/rsa: avoid -Wdiscarded-qualifiers Heinrich Schuchardt
2022-01-10 15:00 ` Alex G. [this message]
2022-01-10 15:06   ` Tom Rini
2022-01-10 16:11     ` Heinrich Schuchardt
2022-01-10 16:12       ` Tom Rini
2022-01-10 16:22         ` Heinrich Schuchardt
2022-01-10 16:29           ` Tom Rini
2022-01-10 16:46             ` Heinrich Schuchardt
2022-01-10 16:48   ` Simon Glass
2022-01-10 16:52     ` Heinrich Schuchardt
2022-01-10 18:47 ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61f8f122-59cb-686d-440f-250aa428dfc9@gmail.com \
    --to=mr.nuke.me@gmail.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=hoiho@lab126.com \
    --cc=mkl@pengutronix.de \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.