From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754909AbbBQXQi (ORCPT ); Tue, 17 Feb 2015 18:16:38 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:50700 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753255AbbBQXQh (ORCPT ); Tue, 17 Feb 2015 18:16:37 -0500 Date: Tue, 17 Feb 2015 23:16:34 +0000 From: Al Viro To: Andrew Morton Cc: Joe Perches , LKML Subject: Re: [PATCH] ipc: Remove uses of return value of seq_printf/seq_puts Message-ID: <20150217231634.GO29656@ZenIV.linux.org.uk> References: <1424202288.25416.5.camel@perches.com> <20150217145246.e0821f61bcebe2e50b057ef9@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150217145246.e0821f61bcebe2e50b057ef9@linux-foundation.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 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.