Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942703AbcJSOld (ORCPT ); Wed, 19 Oct 2016 10:41:33 -0400 Received: from userp1050.oracle.com ([156.151.31.82]:51020 "EHLO userp1050.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S941077AbcJSOl3 (ORCPT ); Wed, 19 Oct 2016 10:41:29 -0400 Date: Wed, 19 Oct 2016 14:22:49 +0300 From: Dan Carpenter To: Brian Masney Cc: jic23@kernel.org, devel@driverdev.osuosl.org, lars@metafoo.de, linux-iio@vger.kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, pmeerw@pmeerw.net, knaack.h@gmx.de Subject: Re: [PATCH 5/7] iio: light: tsl2583: check return values from taos_chip_{on, off} Message-ID: <20161019112249.GH4469@mwanda> References: <1476873130-24926-1-git-send-email-masneyb@onstation.org> <1476873130-24926-5-git-send-email-masneyb@onstation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1476873130-24926-5-git-send-email-masneyb@onstation.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userp1040.oracle.com [156.151.31.81] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1437 Lines: 43 On Wed, Oct 19, 2016 at 06:32:08AM -0400, Brian Masney wrote: > @@ -775,14 +778,20 @@ static ssize_t illuminance0_lux_table_store(struct device *dev, > goto luxable_store_done; > } > > - if (chip->taos_chip_status == TSL258X_CHIP_WORKING) > - taos_chip_off(indio_dev); > + if (chip->taos_chip_status == TSL258X_CHIP_WORKING) { > + ret = taos_chip_off(indio_dev); > + if (ret < 0) > + return ret; > + } > > /* Zero out the table */ > memset(taos_device_lux, 0, sizeof(taos_device_lux)); > memcpy(taos_device_lux, &value[1], (value[0] * 4)); > > - taos_chip_on(indio_dev); > + ret = taos_chip_on(indio_dev); > + if (ret < 0) > + return ret; > + > ret = len; > > luxable_store_done: See, here you are adding direct returns in the middle of a single return function, and you promised yourself that you would never do that and it would mean that you never ever forgot to add error handling. But we're not even outside of the patchset yet and your complicated future proofing has already failed. You know you just want direct returns because that is the simplest way to program. "goto luxable_store_done;" What does that even mean? But "return -EINVAL;" is simple. It does one thing and it does it well. Go with your heart. My research says that the complicated single return functions are going to be buggier in the long run anyway so your heart is leading you on the right path. regards, dan carpenter