Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+7 -4
+7 -4
drivers/media/platform/vicodec/vicodec-core.c
··· 1664 1664 kvfree(state->compressed_frame); 1665 1665 state->compressed_frame = new_comp_frame; 1666 1666 1667 - if (info->components_num >= 3) { 1668 - state->ref_frame.cb = state->ref_frame.luma + size; 1669 - state->ref_frame.cr = state->ref_frame.cb + size / chroma_div; 1670 - } else { 1667 + if (info->components_num < 3) { 1671 1668 state->ref_frame.cb = NULL; 1672 1669 state->ref_frame.cr = NULL; 1670 + state->ref_frame.alpha = NULL; 1671 + return 0; 1673 1672 } 1673 + 1674 + state->ref_frame.cb = state->ref_frame.luma + size; 1675 + state->ref_frame.cr = state->ref_frame.cb + size / chroma_div; 1674 1676 1675 1677 if (info->components_num == 4) 1676 1678 state->ref_frame.alpha = 1677 1679 state->ref_frame.cr + size / chroma_div; 1678 1680 else 1679 1681 state->ref_frame.alpha = NULL; 1682 + 1680 1683 return 0; 1681 1684 } 1682 1685