Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3885010rwa; Tue, 23 Aug 2022 11:52:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR4kzQp/602UinpCE9H3IcJstRdJXemS5/Tc73DYXzEhi4JeLchod4kIMTimd/wpm0JGvIsf X-Received: by 2002:a17:906:5d04:b0:722:f46c:b891 with SMTP id g4-20020a1709065d0400b00722f46cb891mr651135ejt.4.1661280748204; Tue, 23 Aug 2022 11:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661280748; cv=none; d=google.com; s=arc-20160816; b=nY7OMu1HW5L9maeVoK+YvDIIJWZus4h4It2M9JJKrCI/4G8/Ru+G8AHRO7skyqzPfz ELkbnN1queXPyoqOd4CpiMGTmwQRL80clrEPKZ+ORD5Qegq3TRe1ooxkYIT09wOR8OU6 B9ua3ZgeyuUErZXv6v3dXfRp8Zw7iayNPh/caSsFkz1oeVksU6T13rIj6sRipr1sHpv7 OzfkoQ3Bs9DA6LqU2CSXUGgjTPNs5aWAb1+s8xJhSOVspv8WFoys09o/BqUvXSJrUz6s v5cm+jfaLuu35mAQwElL2I72LV6j06xO5s4II/Dduul8GrPRBu/3CgJ7eBgIOdoFllyF dD/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=t5jpD3Lr7k6aJk4JxoOAMMwkBDiTgEB3uo7+kEyrSuY=; b=ssd6hNl4635KMzA4uacNBJXwDkdULjIQNBp9eawELMqsxqXFLVVWGBvc0uLdUfA8vt OPdnixC6m5p5kKUE60Rz6lj/aN14hoL25MRgY/tswnVqq+agSCK1nwQ0Y/nCKxSeRa4D j7Tf53xb1POdqBNZ8hzA47tBOYYIPAcsbAyz4HD2OyPwjN3XJJUWiH/1vS2HqNCf3esP 8/0C7oGtVhmhADDM3SwpjGCXKTMfdYoS0Zw0reJH9nWzKsK5PtFHdzvdSM80kqCje+nf gso/D57IGSdNw14HbWmZIrZdRmtH2ozcISIvhS9OT8TrtJEjKhyPxjIqN7UcQj5znuja oTpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ufjf5RMz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw4-20020a1709066a0400b0072af3e12493si297557ejc.992.2022.08.23.11.52.01; Tue, 23 Aug 2022 11:52:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ufjf5RMz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230320AbiHWRho (ORCPT + 99 others); Tue, 23 Aug 2022 13:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231373AbiHWRhD (ORCPT ); Tue, 23 Aug 2022 13:37:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED8483BD6 for ; Tue, 23 Aug 2022 08:21:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 799B4615D2 for ; Tue, 23 Aug 2022 15:21:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 352D5C433D6; Tue, 23 Aug 2022 15:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661268083; bh=d9e8tVoifQ7GaeXefRpR3cOVTXLtya7HeNbAsuHXZEM=; h=From:To:Cc:Subject:Date:From; b=Ufjf5RMzDjXQxSoiSj0waZ14yrHv3F1SyHQq5i6E3xBrhcUfCg2Nk8ZoA1P7evjbn 8AA3yhgGjGrhhLyiwV1qMESJA/SjAkg3GAn2lmh0FY+8xfYwEpYrBnhy+WvsImQowr cP2+wzU0UK0V0wChQtCtLlWwhxXcQ9IybZ+LP5NFdRqKCew/Cb2X0Mf/s1bNsaNOeA qmDyDxSqXbrU6O/h25ErMzoLpSfGQJ12gqh3QvZaGVwRHLteJLyrIpqIEP90WJpJ6X kEl8aQZfWCKpBnudiznNQ/h+s+uOyN38giitazXl1t7LLZDrqKKo98mrnpv/6M6yud 8P0M8EOU56/5g== From: Nathan Chancellor To: Liam Girdwood , Mark Brown , Matt Flax Cc: Nick Desaulniers , Tom Rix , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Nathan Chancellor , kernel test robot , "Sudip Mukherjee (Codethink)" Subject: [PATCH v2] ASoC: codes: src4xxx: Avoid clang -Wsometimes-uninitialized in src4xxx_hw_params() Date: Tue, 23 Aug 2022 08:19:40 -0700 Message-Id: <20220823151939.2493697-1-nathan@kernel.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns: sound/soc/codecs/src4xxx.c:280:3: error: variable 'd' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ sound/soc/codecs/src4xxx.c:298:59: note: uninitialized use occurs here ret = regmap_write(src4xxx->regmap, SRC4XXX_RCV_PLL_11, d); ^ sound/soc/codecs/src4xxx.c:223:20: note: initialize the variable 'd' to silence this warning int val, pj, jd, d; ^ = 0 sound/soc/codecs/src4xxx.c:280:3: error: variable 'jd' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ sound/soc/codecs/src4xxx.c:293:59: note: uninitialized use occurs here ret = regmap_write(src4xxx->regmap, SRC4XXX_RCV_PLL_10, jd); ^~ sound/soc/codecs/src4xxx.c:223:17: note: initialize the variable 'jd' to silence this warning int val, pj, jd, d; ^ = 0 sound/soc/codecs/src4xxx.c:280:3: error: variable 'pj' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ sound/soc/codecs/src4xxx.c:288:59: note: uninitialized use occurs here ret = regmap_write(src4xxx->regmap, SRC4XXX_RCV_PLL_0F, pj); ^~ sound/soc/codecs/src4xxx.c:223:13: note: initialize the variable 'pj' to silence this warning int val, pj, jd, d; ^ = 0 3 errors generated. The datasheet does not have any default values for these regmap values so pick some arbitrary values and print to the user that this is the case to silence the warnings. Link: https://github.com/ClangBuiltLinux/linux/issues/1691 Reported-by: kernel test robot Reported-by: "Sudip Mukherjee (Codethink)" Suggested-by: Matt Flax Signed-off-by: Nathan Chancellor --- v1 -> v2: https://lore.kernel.org/20220822183101.1115095-1-nathan@kernel.org/ * Don't return early, just initialize the values to some arbitrary numbers and try to hobble along, as other parts of the chip may be functional. * Add message and comment to describe this situation. sound/soc/codecs/src4xxx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/src4xxx.c b/sound/soc/codecs/src4xxx.c index a8f143057b41..db4e280dd055 100644 --- a/sound/soc/codecs/src4xxx.c +++ b/sound/soc/codecs/src4xxx.c @@ -280,9 +280,14 @@ static int src4xxx_hw_params(struct snd_pcm_substream *substream, default: /* don't error out here, * other parts of the chip are still functional + * Dummy initialize variables to avoid + * -Wsometimes-uninitialized from clang. */ dev_info(component->dev, - "Couldn't set the RCV PLL as this master clock rate is unknown\n"); + "Couldn't set the RCV PLL as this master clock rate is unknown. Chosen regmap values may not match real world values.\n"); + pj = 0x0; + jd = 0xff; + d = 0xff; break; } ret = regmap_write(src4xxx->regmap, SRC4XXX_RCV_PLL_0F, pj); base-commit: 94f072748337424c9cf92cd018532a34db3a5516 -- 2.37.2