Skip to contentSkip to conversation

media: rcar_jpu: remove redundant case statement when c is zero

PATCH In review Colin Ian King 2 participants 2 messages May 8, 2025

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

PATCH 1/1 media: rcar_jpu: remove redundant case statement when c is zero

The case statement where c is zero is redundant because the previous while loop will only exit if c is non-zero or non-0xff, so c can never be zero by the time the switch statement is reaced. Clean up the code by removing it.

---
 drivers/media/platform/renesas/rcar_jpu.c | 2 --
 1 file changed, 2 deletions(-)
drivers/media/platform/renesas/rcar_jpu.c +0 -2
index 81038df71bb5..6af154b41eb4 100644
@@ -643,8 +643,6 @@ static u8 jpu_parse_hdr(void *buffer, unsigned long size, unsigned int *width,
 				return 0;
 			skip(&jpeg_buffer, (long)word - 2);
 			break;
-		case 0:
-			break;
 		default:
 			return 0;
 		}
Signature · 1 line
2.49.0
#1 lore raw
Quoted 10 lines · Colin Ian King

The case statement where c is zero is redundant because the previous while loop will only exit if c is non-zero or non-0xff, so c can never be zero by the time the switch statement is reaced. Clean up the code by removing it.

---
 drivers/media/platform/renesas/rcar_jpu.c | 2 --
 1 file changed, 2 deletions(-)
   612  
   613          for (;;) {
   614                  int c;
   615  
   616                  /* skip preceding filler bytes */
   617                  do
   618                          c = get_byte(&jpeg_buffer);
   619                  while (c == 0xff || c == 0);

Unrelated to your commit, but get_byte() returns -1 for out of bounds. I wish there were a explicit check for that. We end up hitting one of the "return 0;" statements depending on if we've found a JPEG_MARKER_SOI.

regards,
dan carpenter