Skip to contentSkip to conversation

staging: atomisp: Fix fallthrough keyword warning

PATCH In review Cengiz Can 4 participants 6 messages Aug 31, 2020

Subsystems (4)
lore
Share & tools
lore

Cengiz Can

author
#0 lore raw

PATCH 1/1 staging: atomisp: Fix fallthrough keyword warning

commit df561f6688fe ("treewide: Use fallthrough pseudo-keyword") from Gustavo A. R. Silva replaced and standardized /* fallthrough */ comments with 'fallthrough' pseudo-keyword.

However, in one of the switch-case statements, Coverity Static Analyzer throws a warning that 'fallthrough' is unreachable due to the adjacent 'return false' statement.

Since 'fallthrough' is actually an empty "do {} while(0)" this might be due to compiler optimizations. But that needs further investigation.

In order to fix the unreachable code warning, make adjacent 'return false' a part of the previous if statement's else clause.

Reported-by Coverity Static Analyzer CID 1466511
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +2 -2
index 1b2b2c68025b..aaa2d0e0851b 100644
@@ -709,8 +709,8 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 		if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
 		    pipe_id == IA_CSS_PIPE_ID_PREVIEW)
 			return true;
-
-		return false;
+		else
+			return false;
 		fallthrough;
 	case ATOMISP_RUN_MODE_VIDEO:
 		if (!asd->continuous_mode->val) {
Signature · 1 line
2.28.0
#1 lore raw
Quoted 25 lines · Cengiz Can

commit df561f6688fe ("treewide: Use fallthrough pseudo-keyword") from Gustavo A. R. Silva replaced and standardized /* fallthrough */ comments with 'fallthrough' pseudo-keyword.

However, in one of the switch-case statements, Coverity Static Analyzer throws a warning that 'fallthrough' is unreachable due to the adjacent 'return false' statement.

Since 'fallthrough' is actually an empty "do {} while(0)" this might be due to compiler optimizations. But that needs further investigation.

In order to fix the unreachable code warning, make adjacent 'return false' a part of the previous if statement's else clause.

Reported-by Coverity Static Analyzer CID 1466511
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -0
index 1b2b2c68025b..aaa2d0e0851b 100644

drivers/staging/media/atomisp/pci/atomisp_compat_css20.c static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd, · line 714

Quoted 8 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +2 -2
@@ -709,8 +709,8 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 		if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
 		    pipe_id == IA_CSS_PIPE_ID_PREVIEW)
 			return true;
-
-		return false;
+		else
+			return false;
 		fallthrough;

Heh... Still unreachable, but now it has a checkpatch.pl warning as well. Just get rid of the bogus fallthrough annotation.

drivers/staging/media/atomisp/pci/atomisp_compat_css20.c static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd, · line 716

Quoted 2 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -0
 	case ATOMISP_RUN_MODE_VIDEO:
 		if (!asd->continuous_mode->val) {

regards,
dan carpenter

#2 lore raw

Really I think this function is pretty buggy. It shouldn't be falling through at all... I reported it a couple days back so it's possible that someone is working on a fix already.

regards,
dan carpenter

author
#3 lore raw

PATCH v2 1/1 staging: atomisp: Remove unnecessary 'fallthrough'

In reply to Dan Carpenter

commit df561f6688fe ("treewide: Use fallthrough pseudo-keyword") from Gustavo A. R. Silva replaced and standardized /* fallthrough */ comments with 'fallthrough' pseudo-keyword.

However, in one of the switch-case statements, Coverity Static Analyzer throws a warning that 'fallthrough' is unreachable due to the adjacent 'return false' statement. (Coverity ID CID 1466511)

In order to fix the unreachable code warning, remove unnecessary fallthrough keyword.

---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -1
index 1b2b2c68025b..feb26c221e96 100644
@@ -711,7 +711,6 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 			return true;
 
 		return false;
-		fallthrough;
 	case ATOMISP_RUN_MODE_VIDEO:
 		if (!asd->continuous_mode->val) {
 			if (pipe_id == IA_CSS_PIPE_ID_VIDEO ||
Signature · 1 line
2.28.0
Reviewed-by on v2 1/1
#4 lore raw

Re: [PATCH v2] staging: atomisp: Remove unnecessary 'fallthrough'

Quoted 4 lines · Cengiz Can

commit df561f6688fe ("treewide: Use fallthrough pseudo-keyword") from Gustavo A. R. Silva replaced and standardized /* fallthrough */ comments with 'fallthrough' pseudo-keyword.

Quoted 8 lines

However, in one of the switch-case statements, Coverity Static Analyzer throws a warning that 'fallthrough' is unreachable due to the adjacent 'return false' statement. (Coverity ID CID 1466511)

In order to fix the unreachable code warning, remove unnecessary fallthrough keyword.

Thanks
--
Gustavo

Quoted 19 lines
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -1
index 1b2b2c68025b..feb26c221e96 100644
@@ -711,7 +711,6 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 			return true;
 
 		return false;
-		fallthrough;
 	case ATOMISP_RUN_MODE_VIDEO:
 		if (!asd->continuous_mode->val) {
 			if (pipe_id == IA_CSS_PIPE_ID_VIDEO ||
Signature · 1 line
2.28.0
#5 lore raw
In reply to Cengiz Can

Em Mon, 31 Aug 2020 16:30:12 +0300
Cengiz Can <[email protected]> escreveu:

Quoted 25 lines

commit df561f6688fe ("treewide: Use fallthrough pseudo-keyword") from Gustavo A. R. Silva replaced and standardized /* fallthrough */ comments with 'fallthrough' pseudo-keyword.

However, in one of the switch-case statements, Coverity Static Analyzer throws a warning that 'fallthrough' is unreachable due to the adjacent 'return false' statement.

Since 'fallthrough' is actually an empty "do {} while(0)" this might be due to compiler optimizations. But that needs further investigation.

In order to fix the unreachable code warning, make adjacent 'return false' a part of the previous if statement's else clause.

Reported-by Coverity Static Analyzer CID 1466511
---
 drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -0
index 1b2b2c68025b..aaa2d0e0851b 100644

drivers/staging/media/atomisp/pci/atomisp_compat_css20.c static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd, · line 714

Quoted 8 lines
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +2 -2
@@ -709,8 +709,8 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,
 		if (pipe_id == IA_CSS_PIPE_ID_CAPTURE ||
 		    pipe_id == IA_CSS_PIPE_ID_PREVIEW)
 			return true;
-
-		return false;
+		else
+			return false;
 		fallthrough;

Actually, the actual fix here would be to get rid of fallthrough.

Regards,

Thanks,
Mauro