mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Louis Langholtz <lou_langholtz@me.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	trivial@kernel.org, Rusty Russell <rusty@rustcorp.com.au>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kernel/params.c: make use of unused but set variable
Date: Thu, 11 Jun 2015 10:54:27 +0900	[thread overview]
Message-ID: <20150611015427.GB3216@mtj.duckdns.org> (raw)
In-Reply-To: <1A6DE1E8-4E0E-4894-A07F-A1EE9AC55835@me.com>

Hey, Louis.

On Wed, Jun 10, 2015 at 11:05:21AM -0600, Louis Langholtz wrote:
> The underlying code for sysfs_create_file does call WARN to warn about
> any errors. So it's not like the code is totally silent anyway. Then the unused

Not any errors.  It triggers warning on missing ops and dup file
names.  The former is a pretty fundamental usage error and we've had
too many of the latter unhandled despite of __must_check.

> but set variable in params.c (that's set to its return value) can be removed
> (and the compiler warning resolved). Incidentally, I do think it'd be helpful
> to comment document this behavior of using WARN so that callers can
> more readily recognize (and be assured that) they won't need to call WARN
> (unless callers want to add __FILE__ and __LINE__ info to the printk output).
> 
> Having functions marked __must_check seems to make more sense when
> their return values are *always* necessary for calling code to have any
> business calling them. Like when there's one or more future calls to functions
> that have to be made (or not made) for the given resource (the kobject) that
> depend on that function's return value (such that the return value state is
> always a later conditional). That doesn't appear to be the case however for
> sysfs_create_file().

I don't know.  Sounds like a weird rule.  We had __must_check, still
had certain error types unhandled so people added explicit WARN to
force people to look into those issues and that means __must_check
should go away?  Sure, if it warns on all errors and can return void
then there's nothing to discuss but that's not the case.  Here, an
error return indicates userland visible behavior difference.  I'd
venture to say that the return value is pretty darn important.

...
> Adding __must_check probably made it easier for developers to identify calling
> code that was depending on success from these functions. At the same time,
> it's not true (at least currently) that these return values always need to

I don't know.  The "always" rule you're speaking of seems too
arbitrary and rigid to me.  Always is a tricky word and tying oneself
to things like that usually doesn't lead to healthy trade-offs.

I don't think removing __must_check would be a disaster but at the
same time these terminal sysfs functions look like the perfect
candidates for such annotations where error returns indicate subtle
but visible behavior differences visible to userland while not
affecting in-kernel operations at all and thus can be easily ignored.

Thanks.

-- 
tejun

  reply	other threads:[~2015-06-11  1:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <http://marc.info/?l=linux-kernel&m=143351431301630>
2015-06-07 23:54 ` Louis Langholtz
2015-06-08  0:00   ` Tejun Heo
2015-06-08  0:17     ` Linus Torvalds
2015-06-08  0:58       ` Tejun Heo
2015-06-08  5:24         ` [PATCH v2] " Louis Langholtz
2015-06-10 17:05         ` [PATCH] " Louis Langholtz
2015-06-11  1:54           ` Tejun Heo [this message]
2015-06-12  3:17             ` Louis Langholtz
2015-06-08  5:44       ` [PATCH] checkpatch: Warn on BUG and BUG_ON uses Joe Perches
2015-06-08  5:46       ` [PATCH] kernel/params.c: make use of unused but set variable Louis Langholtz
2015-06-08  7:12       ` [PATCH] debug: Deprecate BUG_ON() use in new code, introduce CRASH_ON() Ingo Molnar
2015-06-08  7:40         ` Alexander Holler
2015-06-08  8:08           ` Richard Weinberger
2015-06-08  8:42             ` Alexander Holler
2015-06-08  9:05               ` Ingo Molnar
2015-06-08  9:11                 ` Ingo Molnar
2015-06-08  9:22                   ` Alexander Holler
2015-06-08 11:29                     ` Ingo Molnar
2015-06-08  9:16                 ` Alexander Holler
2015-06-08 11:27                   ` Ingo Molnar
2015-06-08 18:07                     ` Alexander Holler
2015-06-08 19:35                       ` Ingo Molnar
2015-06-09  1:07                         ` Alexander Holler
2015-06-08  8:09           ` Ingo Molnar
2015-06-12  1:27       ` [PATCH] kernel/params.c: make use of unused but set variable Rusty Russell
2015-06-12  1:48         ` Tejun Heo
2015-06-14 19:49           ` Rusty Russell
2015-06-16 19:54             ` Tejun Heo

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=20150611015427.GB3216@mtj.duckdns.org \
    --to=htejun@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lou_langholtz@me.com \
    --cc=rusty@rustcorp.com.au \
    --cc=torvalds@linux-foundation.org \
    --cc=trivial@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®