mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: "Aneesh Kumar K.V" <aneesh.kumar@gmail.com>
Cc: linux-kernel@vger.kernel.org, Jesper Juhl <jesper.juhl@gmail.com>,
	Jan Engelhardt <jengelh@linux01.gwdg.de>
Subject: Re: [PATCH] Minor coding style fix
Date: Mon, 09 Oct 2006 16:39:16 +0200	[thread overview]
Message-ID: <452A5F14.2020907@s5r6.in-berlin.de> (raw)
In-Reply-To: <452932F5.7090601@gmail.com>

Aneesh Kumar K.V wrote:
> 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.

The wording is 'can', not 'should' or 'shall'. The current agreement is
however that do_something()-named functions indeed 'should' return <0
for "failure" and 0 for "success" while is_something()-named functions
'should' return non-0 for "yes" and 0 for "no". But there is no rule
without exceptions: Some functions like copy_to_user() return >0 in
situations which can be considered a "failure" because this positive
value has further meaning.

But back to your patch: I am not aware of an agreement on how to write a
check for zero or a check for nonzero.

> I don't see any other value being returned from init_srcu_struct.

True.

> Also having a consistent style of if() check make code reading easier.

Also true. However (a) there is no kernel-wide consistency about this
and (b) the style used in the file which you are patching is
	if (do_something_returning_negative_errors() < 0)
E.g.
http://www.linux-m32r.org/lxr/http/source/kernel/sys.c?v=2.6.19-rc1#L1070

And here <0 and !0 are actually different:
http://www.linux-m32r.org/lxr/http/source/kernel/sys.c?v=2.6.19-rc1#L852

However, kernel/sys.c is not entirely consequent:
http://www.linux-m32r.org/lxr/http/source/kernel/sys.c?v=2.6.19-rc1#L1336
and the other calls to copy_{from,to}_user would have to be
	if (copy_to_user(a, b, s) != 0)
or > 0 to follow the style of the above mentioned ifs to 100%. But
that's nitpicking. :-)
-- 
Stefan Richter
-=====-=-==- =-=- -=---
http://arcgraph.de/sr/

  reply	other threads:[~2006-10-09 14:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-08 15:06 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
2006-10-09 14:39     ` Stefan Richter [this message]
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=452A5F14.2020907@s5r6.in-berlin.de \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=aneesh.kumar@gmail.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=jesper.juhl@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

all inboxes | Powered by JetHome®