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]
Message-ID:  <452932F5.7090601@gmail.com>
Date:	Sun, 08 Oct 2006 22:48:45 +0530
From:	"Aneesh Kumar K.V" <aneesh.kumar@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org
Subject:  Re: [PATCH] Minor coding style fix

Jesper Juhl wrote:
> On 08/10/06, Aneesh Kumar K.V <aneesh.kumar@...il.com> wrote:
>> Kernel generally follow the style
>>
>> if (func()) {
>> /* failed case */
>> } else {
>> /* success */
>> }
>>
>>
> 
> Please submit patches inline, having to copy them from attachments to
> be able to reply is a pain.
> 
>>
>> diff --git a/kernel/sys.c b/kernel/sys.c
>> index 98489d8..55cb77c 100644
>> --- a/kernel/sys.c
>> +++ b/kernel/sys.c
>> @@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(srcu_notifier_call_cha
>>  void srcu_init_notifier_head(struct srcu_notifier_head *nh)
>>  {
>>      mutex_init(&nh->mutex);
>> -    if (init_srcu_struct(&nh->srcu) < 0)
>> +    if (init_srcu_struct(&nh->srcu))
>>          BUG();
>>      nh->head = NULL;
>>  }
> 
> I really liked the old code better. If in the future
> init_srcu_struct() is changed to also return >0 for some conditions,
> then that would not previously have triggered BUG(), but after your
> changes it will. The code, as it were, perfectly expressed what it
> wanted to happen - if it returns less than zero it's a BUG().
> I say leave it alone.
> 
> 


As per Documentation/CodingStyle 

"Functions can return values of many different kinds, and one of the
most common is a value indicating whether the function succeeded or
failed.  Such a value can be represented as an error-code integer
(-Exxx = failure, 0 = success) or a "succeeded" boolean (0 = failure,
non-zero = success)."

That means if the function need to indicate success it should be made to return 0. 
I don't see any other value being returned from init_srcu_struct. Also having a consistent
style of if() check make code reading easier.

-aneesh 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ