[bug report] phy: freescale: fsl-samsung-hdmi: Support dynamic integer
Dan Carpenter
dan.carpenter at linaro.org
Mon Oct 21 02:14:47 PDT 2024
Hello Adam Ford,
Commit 1951dbb41d1d ("phy: freescale: fsl-samsung-hdmi: Support
dynamic integer") from Sep 14, 2024 (linux-next), leads to the
following Smatch static checker warning:
drivers/phy/freescale/phy-fsl-samsung-hdmi.c:510 fsl_samsung_hdmi_phy_lookup_rate()
error: iterator underflow 'phy_pll_cfg' (-1)-69
drivers/phy/freescale/phy-fsl-samsung-hdmi.c
501 static const struct phy_config *fsl_samsung_hdmi_phy_lookup_rate(unsigned long rate)
502 {
503 int i;
504
505 /* Search the lookup table */
506 for (i = ARRAY_SIZE(phy_pll_cfg) - 1; i >= 0; i--)
^^^^^^
What about if we just made the condition "i > 0" here and defaulted to the first
element in the array?
507 if (phy_pll_cfg[i].pixclk <= rate)
508 break;
509
--> 510 return &phy_pll_cfg[i];
Or another idea could but the check for if (i == -1) at the end of the loop.
511 }
regards,
dan carpenter
More information about the linux-phy
mailing list