From 84c9656649b15402cb6523d75ed1204f25db6838 Mon Sep 17 00:00:00 2001 From: Cristina Ciocan Date: Thu, 8 Jun 2017 16:47:38 +0300 Subject: [PATCH] MLK-15027: arm: pxp: Fix uninitialized use of variables This patch fixes build warning that 2 variables may be used uninitialized in the pxp_fetch_config() function in drivers/dma/pxp/pxp_dma_v3.c . The variables in_fmt and out_fmt are passed as parameters to pxp_fetch_shift_calc() only if shift_bypass is false. This flag cannot be false unless changed in a code block that also assigns in_fmt and out_fmt. Since the compiler cannot detect this flow, it shows a warning that in_fmt and out_fmt are not initialized. Fix this by changing the code flow such that in_fmt and out_fmt are sent as parameters in the same code block where they are assigned. Signed-off-by: Cristina Ciocan --- drivers/dma/pxp/pxp_dma_v3.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/dma/pxp/pxp_dma_v3.c b/drivers/dma/pxp/pxp_dma_v3.c index fe3a72b40ae4..9e7cb1106851 100644 --- a/drivers/dma/pxp/pxp_dma_v3.c +++ b/drivers/dma/pxp/pxp_dma_v3.c @@ -2304,23 +2304,27 @@ static int pxp_fetch_config(struct pxp_pixmap *input, shift_bypass = (flags & FETCH_SHIFT) ? 0 : 1; expand_en = (flags & FETCH_EXPAND) ? 1 : 0; - if (!shift_bypass && expand_en) { - if (is_yuv(input->format)) { - in_fmt = PXP_PIX_FMT_YVU444; - out_fmt = PXP_PIX_FMT_YUV444; + if (!shift_bypass) { + if (expand_en) { + if (is_yuv(input->format)) { + in_fmt = PXP_PIX_FMT_YVU444; + out_fmt = PXP_PIX_FMT_YUV444; + } else { + in_fmt = PXP_PIX_FMT_ABGR32; + out_fmt = PXP_PIX_FMT_ARGB32; + } } else { - in_fmt = PXP_PIX_FMT_ABGR32; - out_fmt = PXP_PIX_FMT_ARGB32; + in_fmt = input->format; + out_fmt = is_yuv(input->format) ? + PXP_PIX_FMT_YUV444 : + PXP_PIX_FMT_ARGB32; } - } else if (!shift_bypass) { - in_fmt = input->format; - out_fmt = is_yuv(input->format) ? PXP_PIX_FMT_YUV444 : - PXP_PIX_FMT_ARGB32; + + shift_offset = pxp_fetch_shift_calc(in_fmt, out_fmt, + &shift_width); } } shift_ctrl = pxp_fetch_shift_ctrl_config(input, shift_bypass, expand_en); - if (!shift_bypass) - shift_offset = pxp_fetch_shift_calc(in_fmt, out_fmt, &shift_width); offset = input->crop.y * input->pitch + input->crop.x * (input->bpp >> 3); -- 2.17.1