Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1170857AbdDXNPm (ORCPT ); Mon, 24 Apr 2017 09:15:42 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:35296 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1170841AbdDXNPf (ORCPT ); Mon, 24 Apr 2017 09:15:35 -0400 MIME-Version: 1.0 In-Reply-To: References: <1492780055-4892-1-git-send-email-daniel.baluta@nxp.com> <1492780055-4892-2-git-send-email-daniel.baluta@nxp.com> From: Daniel Baluta Date: Mon, 24 Apr 2017 16:15:33 +0300 Message-ID: Subject: Re: [alsa-devel] [PATCH 1/2] ASoC: codec: wm9860: avoid maybe-uninitialized warning To: Arnd Bergmann Cc: Daniel Baluta , alsa-devel@alsa-project.org, Linux Kernel Mailing List , patches@opensource.wolfsonmicro.com, Takashi Iwai , Liam Girdwood , Mark Brown , Charles Keepax Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v3ODFjQS009299 Content-Length: 3714 Lines: 90 On Fri, Apr 21, 2017 at 5:46 PM, Arnd Bergmann wrote: > On Fri, Apr 21, 2017 at 3:07 PM, Daniel Baluta wrote: >> The new PLL configuration code triggers a harmless warning: >> >> sound/soc/codecs/wm8960.c: In function 'wm8960_configure_clocking': >> sound/soc/codecs/wm8960.c:735:3: error: 'best_freq_out' may be used >> uninitialized in this function [-Werror=maybe-uninitialized] >> wm8960_set_pll(codec, freq_in, best_freq_out); >> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> sound/soc/codecs/wm8960.c:699:12: note: 'best_freq_out' was declared >> here >> >> Fixes: 84fdc00d519f ("ASoC: codec: wm9860: Refactor PLL out freq search") >> Fixes: 303e8954af8d ("ASoC: codec: wm8960: Stop when a matching PLL freq is found") >> Suggested-by: Arnd Bergmann >> Signed-off-by: Daniel Baluta >> --- >> Arnd, >> >> I agree that your code was more both humans and gcc anyhow >> for consistency with wm8960_configure_sysclk function I preferred >> to keep the "if(..) break" statements. > > How about changing both functions the same way then? I've tried but I couldn't find any solution. For clarity here is how the code actually looks like. The git diff is a little bit misleading. Here is how wm8960_configure_pll code looks like: https://pastebin.com/naGdVNQz static int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, » » » int *sysclk_idx, int *dac_idx, int *bclk_idx) { » struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); » int sysclk, bclk, lrclk, freq_out; » int diff, closest, best_freq_out; » int i, j, k; » bclk = wm8960->bclk; » lrclk = wm8960->lrclk; » closest = freq_in; » best_freq_out = -EINVAL; » *sysclk_idx = *dac_idx = *bclk_idx = -1; » for (i = 0; i < ARRAY_SIZE(sysclk_divs); ++i) { » » if (sysclk_divs[i] == -1) » » » continue; » » for (j = 0; j < ARRAY_SIZE(dac_divs); ++j) { » » » sysclk = lrclk * dac_divs[j]; » » » freq_out = sysclk * sysclk_divs[i]; » » » for (k = 0; k < ARRAY_SIZE(bclk_divs); ++k) { » » » » if (!is_pll_freq_available(freq_in, freq_out)) » » » » » continue; » » » » diff = sysclk - bclk * bclk_divs[k] / 10; » » » » if (diff == 0) { » » » » » *sysclk_idx = i; » » » » » *dac_idx = j; » » » » » *bclk_idx = k; » » » » » best_freq_out = freq_out; » » » » » break; » » » » } » » » » if (diff > 0 && closest > diff) { » » » » » *sysclk_idx = i; » » » » » *dac_idx = j; » » » » » *bclk_idx = k; » » » » » closest = diff; » » » » » best_freq_out = freq_out; » » » » } » » » } » » » if (k != ARRAY_SIZE(bclk_divs)) » » » » break; » » } » » if (j != ARRAY_SIZE(dac_divs)) » » » break; » } » return best_freq_out; } In my opinion this is a compiler false positive. Any clue on how to rework this would be welcomed :). I couldn't find any decent solution. Daniel.