[lkml]   [2015]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] ipc: Remove uses of return value of seq_printf/seq_puts
On Tue, Feb 17, 2015 at 02:52:46PM -0800, Andrew Morton wrote:
> On Tue, 17 Feb 2015 11:44:48 -0800 Joe Perches <> 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.

 \ /
  Last update: 2015-02-18 00:21    [W:0.043 / U:6.320 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site