Skip to contentSkip to conversation

media: imx: imx7_mipi_csis: convert some switch cases to the default

PATCH In review [email protected] 3 participants 3 messages May 31, 2021 – Jun 1, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: imx: imx7_mipi_csis: convert some switch cases to the default

From: Tom Rix <[email protected]>

Static analysis reports this false positive imx7-mipi-csis.c:1027:2: warning: 4th function call argument is
an uninitialized value

The variable 'align' is falsely reported as uninitialized. Even though all the cases are covered in the

	switch (csis_fmt->width % 8) {

Because there is no default case, it is reported as uninialized.

Improve the switch by converting the most numerous set of cases to the default and silence the false positive.

---
 drivers/staging/media/imx/imx7-mipi-csis.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +2 -4
index d573f3475d28..330f283030ec 100644
@@ -1016,10 +1016,8 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
 	case 6:
 		align = 2;
 		break;
-	case 1:
-	case 3:
-	case 5:
-	case 7:
+	default:
+		/* 1, 3, 5, 7 */
 		align = 3;
 		break;
 	}
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw

Hi Tom,
Thanks for the patch.

Quoted 8 lines · WEST,

From: Tom Rix <[email protected]>

Static analysis reports this false positive imx7-mipi-csis.c:1027:2: warning: 4th function call argument is
an uninitialized value

The variable 'align' is falsely reported as uninitialized. Even though all the cases are covered in the

Quoted 8 lines
	switch (csis_fmt->width % 8) {

Because there is no default case, it is reported as uninialized.

Improve the switch by converting the most numerous set of cases to the default and silence the false positive.

It solves that, looks good to me.

------
Cheers,
Rui

Quoted 23 lines
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +2 -4
index d573f3475d28..330f283030ec 100644
@@ -1016,10 +1016,8 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
 	case 6:
 		align = 2;
 		break;
-	case 1:
-	case 3:
-	case 5:
-	case 7:
+	default:
+		/* 1, 3, 5, 7 */
 		align = 3;
 		break;
 	}
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#2 lore raw
In reply to [email protected]

Hi Tom,

Thank you for the patch.

Quoted 8 lines · On Mon, May 31, 2021 at 10:43:00AM -0700, [email protected] wrote:

From: Tom Rix <[email protected]>

Static analysis reports this false positive imx7-mipi-csis.c:1027:2: warning: 4th function call argument is
an uninitialized value

The variable 'align' is falsely reported as uninitialized. Even though all the cases are covered in the

Quoted 8 lines
	switch (csis_fmt->width % 8) {

Because there is no default case, it is reported as uninialized.

Improve the switch by converting the most numerous set of cases to the default and silence the false positive.

Quoted 21 lines
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/media/imx/imx7-mipi-csis.c +2 -4
index d573f3475d28..330f283030ec 100644
@@ -1016,10 +1016,8 @@ static int mipi_csis_set_fmt(struct v4l2_subdev *sd,
 	case 6:
 		align = 2;
 		break;
-	case 1:
-	case 3:
-	case 5:
-	case 7:
+	default:
+		/* 1, 3, 5, 7 */
 		align = 3;
 		break;
 	}
Signature · 3 lines
Regards,

Laurent Pinchart