[PATCH 16/17] media: st: delta: introduce 'err_too_many_comps' label

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The code mixed gotos and returns, which confused smatch. Add a
err_too_many_comps label to handle the error instead of a return,
this helps smatch understand the code, and it's a bit more consistent
as well.

This fixes this smatch warning:

delta-mjpeg-hdr.c:67 delta_mjpeg_read_sof() warn: missing unwind goto?

Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
Cc: Hugues Fruchet <hugues.fruchet@xxxxxxxxxxx>
---
 .../platform/st/sti/delta/delta-mjpeg-hdr.c      | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c b/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c
index 90e5b2f72c82..c132487637d3 100644
--- a/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c
+++ b/drivers/media/platform/st/sti/delta/delta-mjpeg-hdr.c
@@ -59,13 +59,8 @@ static int delta_mjpeg_read_sof(struct delta_ctx *pctx,
 	header->nb_of_components = *(u8 *)(data + offset);
 	offset += sizeof(u8);
 
-	if (header->nb_of_components >= MJPEG_MAX_COMPONENTS) {
-		dev_err(delta->dev,
-			"%s   unsupported number of components (%d > %d)\n",
-			pctx->name, header->nb_of_components,
-			MJPEG_MAX_COMPONENTS);
-		return -EINVAL;
-	}
+	if (header->nb_of_components >= MJPEG_MAX_COMPONENTS)
+		goto err_too_many_comps;
 
 	if ((offset + header->nb_of_components *
 	     sizeof(header->components[0])) > size)
@@ -78,6 +73,13 @@ static int delta_mjpeg_read_sof(struct delta_ctx *pctx,
 		"%s   sof: reached end of %d size input stream\n",
 		pctx->name, size);
 	return -ENODATA;
+
+err_too_many_comps:
+	dev_err(delta->dev,
+		"%s   unsupported number of components (%d > %d)\n",
+		pctx->name, header->nb_of_components,
+		MJPEG_MAX_COMPONENTS);
+	return -EINVAL;
 }
 
 int delta_mjpeg_read_header(struct delta_ctx *pctx,
-- 
2.39.0




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux