lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202601291605277bc279f4@mail.local>
Date: Thu, 29 Jan 2026 17:05:27 +0100
From: Alexandre Belloni <alexandre.belloni@...tlin.com>
To: rouven.czerwinski@...aro.org
Cc: Jens Wiklander <jens.wiklander@...aro.org>,
	Sumit Garg <sumit.garg@...nel.org>,
	Olivia Mackall <olivia@...enic.com>,
	Herbert Xu <herbert@...dor.apana.org.au>,
	Clément Léger <clement.leger@...tlin.com>,
	op-tee@...ts.trustedfirmware.org, linux-kernel@...r.kernel.org,
	linux-crypto@...r.kernel.org, linux-rtc@...r.kernel.org
Subject: Re: [PATCH 3/3] rtc: optee: simplify OP-TEE context match

On 26/01/2026 11:11:26+0100, Rouven Czerwinski via B4 Relay wrote:
> From: Rouven Czerwinski <rouven.czerwinski@...aro.org>
> 
> Simplify the TEE implementor ID match by returning the boolean
> expression directly instead of going through an if/else.
> 
> Signed-off-by: Rouven Czerwinski <rouven.czerwinski@...aro.org>
> ---
>  drivers/rtc/rtc-optee.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-optee.c b/drivers/rtc/rtc-optee.c
> index 184c6d142801..2f18be3de684 100644
> --- a/drivers/rtc/rtc-optee.c
> +++ b/drivers/rtc/rtc-optee.c
> @@ -541,10 +541,7 @@ static int optee_rtc_read_info(struct device *dev, struct rtc_device *rtc,
>  
>  static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
>  {
> -	if (ver->impl_id == TEE_IMPL_ID_OPTEE)
> -		return 1;
> -	else
> -		return 0;
> +	return (ver->impl_id == TEE_IMPL_ID_OPTEE);

I guess the correct way to do this would be:

return !!(ver->impl_id == TEE_IMPL_ID_OPTEE);

But is this change actually generating better code?

Before:

static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
{
        if (ver->impl_id == TEE_IMPL_ID_OPTEE)
       0:       e5900000        ldr     r0, [r0]
                return 1;
        else
                return 0;
}
       4:       e2400001        sub     r0, r0, #1
       8:       e16f0f10        clz     r0, r0
       c:       e1a002a0        lsr     r0, r0, #5
      10:       e12fff1e        bx      lr

After:

static int optee_ctx_match(struct tee_ioctl_version_data *ver, const void *data)
{
        return !!(ver->impl_id == TEE_IMPL_ID_OPTEE);
       0:       e5900000        ldr     r0, [r0]
}
       4:       e2400001        sub     r0, r0, #1
       8:       e16f0f10        clz     r0, r0
       c:       e1a002a0        lsr     r0, r0, #5
      10:       e12fff1e        bx      lr

I'm in favor of keeping the current version.

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ