From: Al Viro <viro@ZenIV.linux.org.uk>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Joe Perches <joe@perches.com>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ipc: Remove uses of return value of seq_printf/seq_puts
Date: Tue, 17 Feb 2015 23:16:34 +0000 [thread overview]
Message-ID: <20150217231634.GO29656@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20150217145246.e0821f61bcebe2e50b057ef9@linux-foundation.org>
On Tue, Feb 17, 2015 at 02:52:46PM -0800, Andrew Morton wrote:
> On Tue, 17 Feb 2015 11:44:48 -0800 Joe Perches <joe@perches.com> wrote:
>
> > These functions are soon going to return void
>
> That's news to me.
>
> > so remove the
> > return value uses.
> >
> > Convert the return value to test seq_has_overflowed() instead.
>
> Why not make seq_printf() return seq_has_overflowed()?
Because we are getting well-meaning folks who try to check that return value,
again and again, getting it wrong every time. Typical idiocies:
* return some kind of error out of ->show() on overflows. Pointless
*and* wrong - only hard errors (== fail read(2) with that) should be
reported that way; the caller does detect overflow and retires with bigger
buffer just fine.
* keep checking it after every sodding call of seq_...(), screwing
the cleanups up more often than not. Pointless, unless you are doing some
seriously expensive calculations to produce something you are going to print.
seq_...() are no-ops in case when overflow has already happened.
seq_had_overflowed() is only for situations when you really want to skip
a serious amount of work generating the data that would end up being
discarded and recalculated again when the caller grabs a bigger buffer and
calls you again. And more often than not it's an indication of ->show()
trying to do the work of iterator - e.g. when you have single_open() with
->show() printing the entire hash table of some sort all in one record.
Most of the time checking return value of seq_...() is better replaced with
not doing that. And "must check return value and Do Something(tm)" is too
strong habit for enough people to cause recurring trouble.
next prev parent reply other threads:[~2015-02-17 23:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 19:44 [PATCH] ipc: Remove uses of return value of seq_printf/seq_puts Joe Perches
2015-02-17 22:52 ` Andrew Morton
2015-02-17 23:02 ` Joe Perches
2015-02-17 23:16 ` Al Viro [this message]
2015-02-18 0:09 ` Joe Perches
2015-02-18 0:27 ` Al Viro
2015-02-18 0:55 ` Joe Perches
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=20150217231634.GO29656@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.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