mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: platform: return early if the iface is not handled
@ 2022-03-19 14:34 trix
  2022-04-05 17:53 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2022-03-19 14:34 UTC (permalink / raw)
  To: laurent.pinchart, mchehab, nathan, ndesaulniers
  Cc: linux-media, linux-kernel, llvm, Tom Rix

From: Tom Rix <trix@redhat.com>

Clang static analysis reports this issue
ispcsiphy.c:63:14: warning: The left operand of '<<'
  is a garbage value
        reg |= mode << shift;
               ~~~~ ^
The iface switch-statement default case falls through
to ISP_INTERFACE_CCP2B_PHY1.  Which is later checked
to set the mode.  Since the default case is left out
of this check mode is never set.  Instead of falling
through and assuming a ISP_INTERFACE_CCP2B_PHY1
iface, return.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/media/platform/ti/omap3isp/ispcsiphy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti/omap3isp/ispcsiphy.c b/drivers/media/platform/ti/omap3isp/ispcsiphy.c
index 6dc7359c5131d..1bde76c0adbee 100644
--- a/drivers/media/platform/ti/omap3isp/ispcsiphy.c
+++ b/drivers/media/platform/ti/omap3isp/ispcsiphy.c
@@ -31,7 +31,8 @@ static void csiphy_routing_cfg_3630(struct isp_csiphy *phy,
 
 	switch (iface) {
 	default:
-	/* Should not happen in practice, but let's keep the compiler happy. */
+		/* Should not happen in practice, but let's keep the compiler happy. */
+		return;
 	case ISP_INTERFACE_CCP2B_PHY1:
 		reg &= ~OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2;
 		shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT;
-- 
2.26.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: platform: return early if the iface is not handled
  2022-03-19 14:34 [PATCH] media: platform: return early if the iface is not handled trix
@ 2022-04-05 17:53 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2022-04-05 17:53 UTC (permalink / raw)
  To: trix; +Cc: laurent.pinchart, mchehab, nathan, linux-media, linux-kernel, llvm

On Sat, Mar 19, 2022 at 7:35 AM <trix@redhat.com> wrote:
>
> From: Tom Rix <trix@redhat.com>
>
> Clang static analysis reports this issue
> ispcsiphy.c:63:14: warning: The left operand of '<<'
>   is a garbage value
>         reg |= mode << shift;
>                ~~~~ ^
> The iface switch-statement default case falls through
> to ISP_INTERFACE_CCP2B_PHY1.  Which is later checked
> to set the mode.  Since the default case is left out
> of this check mode is never set.  Instead of falling
> through and assuming a ISP_INTERFACE_CCP2B_PHY1
> iface, return.
>
> Signed-off-by: Tom Rix <trix@redhat.com>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/media/platform/ti/omap3isp/ispcsiphy.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/ti/omap3isp/ispcsiphy.c b/drivers/media/platform/ti/omap3isp/ispcsiphy.c
> index 6dc7359c5131d..1bde76c0adbee 100644
> --- a/drivers/media/platform/ti/omap3isp/ispcsiphy.c
> +++ b/drivers/media/platform/ti/omap3isp/ispcsiphy.c
> @@ -31,7 +31,8 @@ static void csiphy_routing_cfg_3630(struct isp_csiphy *phy,
>
>         switch (iface) {
>         default:
> -       /* Should not happen in practice, but let's keep the compiler happy. */
> +               /* Should not happen in practice, but let's keep the compiler happy. */
> +               return;
>         case ISP_INTERFACE_CCP2B_PHY1:
>                 reg &= ~OMAP3630_CONTROL_CAMERA_PHY_CTRL_CSI1_RX_SEL_PHY2;
>                 shift = OMAP3630_CONTROL_CAMERA_PHY_CTRL_CAMMODE_PHY1_SHIFT;
> --
> 2.26.3
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-06  2:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-19 14:34 [PATCH] media: platform: return early if the iface is not handled trix
2022-04-05 17:53 ` Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®