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] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 6 Jun 2014 09:35:12 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Pranith Kumar <pranith@...ech.edu>
Cc:	linux-kernel@...r.kernel.org, tim.c.chen@...ux.intel.com,
	davidlohr@...com, mingo@...hat.com
Subject: Re: [RFC PATCH 1/1] cleanup: use bool as return type for
 rwsem_is_locked

On Thu, Jun 05, 2014 at 04:49:37PM -0400, Pranith Kumar wrote:
> I see that there are functions like this which basically say:
> 
> return 1 if true else return 0. Is it worth cleaning them up? Or is
> there any reason why this convention is followed?

Hysterical raisins, a lot of people learnt C before it grew bool,
including me.

> use bool as the return type. No reason for return type to be int.
> 
> Signed-off-by: Pranith Kumar <bobby.prani@...il.com>
> ---

> diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c
> index 9be8a91..7374139 100644
> --- a/kernel/locking/rwsem-spinlock.c
> +++ b/kernel/locking/rwsem-spinlock.c
> @@ -20,7 +20,7 @@ struct rwsem_waiter {
>  	enum rwsem_waiter_type type;
>  };
>  
> -int rwsem_is_locked(struct rw_semaphore *sem)
> +bool rwsem_is_locked(struct rw_semaphore *sem)
>  {
>  	int ret = 1;
>  	unsigned long flags;

Now, see that's a half arsed change, if you change the function return
value, you should also change the value we actually return, @ret above
to bool, and you should then also change the values used to 'true' and
'false'.

Now in general, I don't particularly like such superfluous changes, so
unless you can show that GCC actually generates better code, I'd prefer
to keep things as they are.

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ