public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Minor coding style fix
Date: Sun, 08 Oct 2006 22:48:45 +0530	[thread overview]
Message-ID: <452932F5.7090601@gmail.com> (raw)
In-Reply-To: <9a8748490610080829r54053e14ud8c7b02c8f39476c@mail.gmail.com>

Jesper Juhl wrote:
> On 08/10/06, Aneesh Kumar K.V <aneesh.kumar@gmail.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 


  parent reply	other threads:[~2006-10-08 17:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-08 15:06 [PATCH] Minor coding style fix Aneesh Kumar K.V
2006-10-08 15:29 ` Jesper Juhl
2006-10-08 15:42   ` Jan Engelhardt
2006-10-08 17:18   ` Aneesh Kumar K.V [this message]
2006-10-09 14:39     ` Stefan Richter
  -- strict thread matches above, loose matches on Subject: below --
2017-03-27 14:34 [PATCH] minor " sfaragnaus
2017-03-29  7:18 ` Greg Kroah-Hartman

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=452932F5.7090601@gmail.com \
    --to=aneesh.kumar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox