summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-08-22 11:41:45 -0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-08-26 14:02:22 -0300
commitcb8045072a34d113e51fcd19cec74359b4e8daa9 (patch)
treeb4a6d1f30da2171e76f1cf385a163fe0e1bfd602
parent59364e971c1c4e2bcf45ee118507d60609337de8 (diff)
media: vicodec: make life easier for static analyzers
cppcheck incorrectly produces an error here: [drivers/media/platform/vicodec/vicodec-core.c:1677]: (error) Pointer addition with NULL pointer. While this is actually a false positive, it doesn't hurt to reorder the checks to make the code simpler, handling first the error patch, where no color or alpha components are there. Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--drivers/media/platform/vicodec/vicodec-core.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/media/platform/vicodec/vicodec-core.c b/drivers/media/platform/vicodec/vicodec-core.c
index 5152f44bcc0a..0ee143ae0f6b 100644
--- a/drivers/media/platform/vicodec/vicodec-core.c
+++ b/drivers/media/platform/vicodec/vicodec-core.c
@@ -1664,19 +1664,22 @@ static int vicodec_start_streaming(struct vb2_queue *q,
kvfree(state->compressed_frame);
state->compressed_frame = new_comp_frame;
- if (info->components_num >= 3) {
- state->ref_frame.cb = state->ref_frame.luma + size;
- state->ref_frame.cr = state->ref_frame.cb + size / chroma_div;
- } else {
+ if (info->components_num < 3) {
state->ref_frame.cb = NULL;
state->ref_frame.cr = NULL;
+ state->ref_frame.alpha = NULL;
+ return 0;
}
+ state->ref_frame.cb = state->ref_frame.luma + size;
+ state->ref_frame.cr = state->ref_frame.cb + size / chroma_div;
+
if (info->components_num == 4)
state->ref_frame.alpha =
state->ref_frame.cr + size / chroma_div;
else
state->ref_frame.alpha = NULL;
+
return 0;
}