From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D20B6C433E0 for ; Tue, 12 Jan 2021 10:25:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95944206F1 for ; Tue, 12 Jan 2021 10:25:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406126AbhALKZG (ORCPT ); Tue, 12 Jan 2021 05:25:06 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:49871 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730230AbhALKZF (ORCPT ); Tue, 12 Jan 2021 05:25:05 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kzGqc-0005sK-0f; Tue, 12 Jan 2021 10:24:22 +0000 Subject: Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret To: Dan Carpenter Cc: Mark Brown , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , =?UTF-8?B?5pyx54G/54G/?= , alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210108123546.19601-1-colin.king@canonical.com> <20210111163551.GA33269@sirena.org.uk> <9bef4fe5-0eed-03f8-9505-909b669ba49b@canonical.com> <20210112102204.GG5083@kadam> From: Colin Ian King Message-ID: <69547a3a-8b58-69cc-af87-fac7b7d03cb4@canonical.com> Date: Tue, 12 Jan 2021 10:24:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210112102204.GG5083@kadam> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/01/2021 10:22, Dan Carpenter wrote: > On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote: >> On 11/01/2021 16:35, Mark Brown wrote: >>> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote: >>>> From: Colin Ian King >>>> >>>> Currently when attempting to start the BE fails because the >>>> FE is not started the error return variable ret is not initialized >>>> and garbage is returned. Fix this by setting it to 0 so the >>> >>> This doesn't apply against current code, please check and resend. >>> >> >> Current ASoC tree now has two commits: >> >> commit 4eeed5f40354735c4e68e71904db528ed19c9cbb >> Author: Souptick Joarder >> Date: Sat Jan 9 09:15:01 2021 +0530 >> >> ASoC: soc-pcm: return correct -ERRNO in failure path >> >> commit e91b65b36fde0690f1c694f17dd1b549295464a7 >> Author: Dan Carpenter >> Date: Mon Jan 11 12:50:21 2021 +0300 >> >> ASoC: soc-pcm: Fix an uninitialized error code >> >> ..both set ret to non-zero, which I believe will throw a subsequent >> warning messagethat's not strictly related. > > My patch restored the original behavior. And I think that errors should > return error codes. What you're saying is basically "Returning an error > is a bug because it will trigger an error message in the caller". So > then we have to have a debate about printks as a layering violation. > > I don't like error messages generally, because I think they make the > code messy. A lot of people put error messages for impossible things. > Or if a kmalloc() fails or whatever. There are too many error messages > which people add in an auto-pilot way without considering whether it's > necessary. > > But some people think, and maybe they're correct, that it's best if > every function in the call tree prints a message. That way you can > trace the error path easily. +1 Yep, good point, ignore my fix. Thanks Dan for your observations. > > regards, > dan carpenter > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Colin Ian King Date: Tue, 12 Jan 2021 10:24:21 +0000 Subject: Re: [PATCH][next] ASoC: soc-pcm: Fix uninitialised return value in variable ret Message-Id: <69547a3a-8b58-69cc-af87-fac7b7d03cb4@canonical.com> List-Id: References: <20210108123546.19601-1-colin.king@canonical.com> <20210111163551.GA33269@sirena.org.uk> <9bef4fe5-0eed-03f8-9505-909b669ba49b@canonical.com> <20210112102204.GG5083@kadam> In-Reply-To: <20210112102204.GG5083@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Dan Carpenter Cc: alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org, =?UTF-8?B?5pyx54G/54G/?= , Takashi Iwai , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org On 12/01/2021 10:22, Dan Carpenter wrote: > On Mon, Jan 11, 2021 at 05:37:36PM +0000, Colin Ian King wrote: >> On 11/01/2021 16:35, Mark Brown wrote: >>> On Fri, Jan 08, 2021 at 12:35:46PM +0000, Colin King wrote: >>>> From: Colin Ian King >>>> >>>> Currently when attempting to start the BE fails because the >>>> FE is not started the error return variable ret is not initialized >>>> and garbage is returned. Fix this by setting it to 0 so the >>> >>> This doesn't apply against current code, please check and resend. >>> >> >> Current ASoC tree now has two commits: >> >> commit 4eeed5f40354735c4e68e71904db528ed19c9cbb >> Author: Souptick Joarder >> Date: Sat Jan 9 09:15:01 2021 +0530 >> >> ASoC: soc-pcm: return correct -ERRNO in failure path >> >> commit e91b65b36fde0690f1c694f17dd1b549295464a7 >> Author: Dan Carpenter >> Date: Mon Jan 11 12:50:21 2021 +0300 >> >> ASoC: soc-pcm: Fix an uninitialized error code >> >> ..both set ret to non-zero, which I believe will throw a subsequent >> warning messagethat's not strictly related. > > My patch restored the original behavior. And I think that errors should > return error codes. What you're saying is basically "Returning an error > is a bug because it will trigger an error message in the caller". So > then we have to have a debate about printks as a layering violation. > > I don't like error messages generally, because I think they make the > code messy. A lot of people put error messages for impossible things. > Or if a kmalloc() fails or whatever. There are too many error messages > which people add in an auto-pilot way without considering whether it's > necessary. > > But some people think, and maybe they're correct, that it's best if > every function in the call tree prints a message. That way you can > trace the error path easily. +1 Yep, good point, ignore my fix. Thanks Dan for your observations. > > regards, > dan carpenter >