From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932115AbaIQUgu (ORCPT ); Wed, 17 Sep 2014 16:36:50 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:63661 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756245AbaIQUgq (ORCPT ); Wed, 17 Sep 2014 16:36:46 -0400 Date: Wed, 17 Sep 2014 22:36:40 +0200 From: Frans Klaver To: Darren Hart Cc: Paul Bolle , Corentin Chary , "Rafael J. Wysocki" , Greg Kroah-Hartman , Matthew Garrett , Rafael Wysocki , acpi4asus-user@lists.sourceforge.net, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] eeepc-laptop: simplify parse_arg() Message-ID: <20140917203640.GB4432@gmail.com> References: <7288841.ayNsq2yeGO@vostro.rjw.lan> <1410252608.22255.5.camel@x220> <20140910033304.GB39541@vmdeb7> <20140910164916.GA48285@vmdeb7> <1410379520.11097.18.camel@x220> <20140911223739.GB18425@vmdeb7> <20140916234543.GA22408@vmdeb7> <1410980571.10248.6.camel@x220> <20140917203510.GA12682@vmdeb7> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20140917203510.GA12682@vmdeb7> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 17, 2014 at 01:35:10PM -0700, Darren Hart wrote: > On Wed, Sep 17, 2014 at 09:02:51PM +0200, Paul Bolle wrote: > > parse_arg() has three possible return values: > > -EINVAL if sscanf(), in short, fails; > > zero if "count" is zero; and > > "count" in all other cases > > > > But "count" will never be zero. See, parse_arg() is called by the > > various store functions. And the callchain of these functions starts > > with sysfs_kf_write(). And that function checks for a zero "count". So > > we can stop checking for a zero "count", drop the "count" argument > > entirely, and transform parse_arg() into a function that returns zero on > > success or a negative error. That, in turn, allows to make those store > > functions just return "count" on success. The net effect is that the > > code becomes a bit easier to understand. > > > > A nice side effect is that this GCC warning is silenced too: > > drivers/platform/x86/eeepc-laptop.c: In function ‘store_sys_acpi’: > > drivers/platform/x86/eeepc-laptop.c:279:10: warning: ‘value’ may be used uninitialized in this function [-Wmaybe-uninitialized] > > int rv, value; > > > > Which is, of course, the reason to have a look at parse_arg(). > > > > Signed-off-by: Paul Bolle > > --- > > Still build tested only, but now on top of v3.17-rc5. Has Frans tested > > writing zero length values to these sysfs files? > > Frans, can you confirm testing when you get a chance please? Will do. Frans