]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ASoC: Intel: Skylake: Re-order some code to silence a warning
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 8 Dec 2017 11:54:25 +0000 (14:54 +0300)
committerMark Brown <broonie@kernel.org>
Mon, 11 Dec 2017 11:43:15 +0000 (11:43 +0000)
I get a Smatch warning here:

    sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks()
    error: testing array offset 'j' after use.

The code is harmless, but the checker is right that we should swap these
two conditions so we verify that the offset is within bounds before we
use it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Sriram Periyasamy <sriramx.periyasamy@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-nhlt.c

index ca5dc2be7b6826bcad7c1805c864c7150f794c6b..bde7f40f29f5c61da3c2794d10a5ace90f69a03a 100644 (file)
@@ -322,8 +322,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
                rate = channels * bps * fs;
 
                /* check if the rate is added already to the given SSP's sclk */
-               for (j = 0; (sclk[id].rate_cfg[j].rate != 0) &&
-                               (j < SKL_MAX_CLK_RATES); j++) {
+               for (j = 0; (j < SKL_MAX_CLK_RATES) &&
+                           (sclk[id].rate_cfg[j].rate != 0); j++) {
                        if (sclk[id].rate_cfg[j].rate == rate) {
                                present = true;
                                break;