From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbbCIPYH (ORCPT ); Mon, 9 Mar 2015 11:24:07 -0400 Received: from mail-wi0-f172.google.com ([209.85.212.172]:44562 "EHLO mail-wi0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751061AbbCIPYD (ORCPT ); Mon, 9 Mar 2015 11:24:03 -0400 Message-ID: <54FDBB05.60408@gmail.com> Date: Mon, 09 Mar 2015 17:23:49 +0200 From: =?UTF-8?B?R2llZHJpdXMgU3RhdGtldmnEjWl1cw==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Dan Carpenter , Matteo Semenzato CC: lidza.louina@gmail.com, markh@compro.net, devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dgnc: move more repeating code under 'failed' label References: <1425836797-3632-1-git-send-email-giedrius.statkevicius@gmail.com> <20150309130645.GF10964@mwanda> In-Reply-To: <20150309130645.GF10964@mwanda> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015.03.09 15:06, Dan Carpenter wrote: > Added Matteo to the CC list because he was working on this function as > well and I remembered something I wanted to tell him. > > On Sun, Mar 08, 2015 at 07:46:37PM +0200, Giedrius Statkevičius wrote: >> Currently the label is only used to return a error code to the caller but more >> repeating code is before each "goto failed;" thus we can move that code to the >> label. Also, remove some empty unneeded lines together with this patch in those >> if's and at the end of dgnc_found_board(). >> > > This function totally sucks. > > This patch is useless because we will never use the brd->state in the > cases where we fail. We shouldn't be saving inconsistent crap into > dgnc_Board[] because that is barf inducing ugly even though it's not a > bug given that we don't use it. > > Only do: > > dgnc_Board[dgnc_NumBoards] = brd; > > when the brd is fully configured at the end of the dgnc_found_board() > function. > > regards, > dan carpenter First time I've made this patch I was purely looking at this from a cosmetical point. But now that I've looked more at this I see that you have a good point. I've made a patch that tries to address this issue and posted it in another thread. -- Thanks, Giedrius