media: davinci-isif: avoid uninitialized variable use
PATCH 1/1 media: davinci-isif: avoid uninitialized variable use
clang warns about a possible variable use that gcc never complained about:
drivers/media/platform/davinci/isif.c:982:32: error: variable 'frame_size' is uninitialized when used here
[-Werror,-Wuninitialized]
dm365_vpss_set_pg_frame_size(frame_size);
^~~~~~~~~~
drivers/media/platform/davinci/isif.c:887:2: note: variable 'frame_size' is declared here
struct vpss_pg_frame_size frame_size;
^1 error generated.
There is no initialization for this variable at all, and there has never been one in the mainline kernel, so we really should not put that stack data into an mmio register.
On the other hand, I suspect that gcc checks the condition more closely and notices that the global isif_cfg.bayer.config_params.test_pat_gen flag is initialized to zero and never written to from any code path, so anything depending on it can be eliminated.
To shut up the clang warning, just remove the dead code manually, it has probably never been used because any attempt to do so would have resulted in undefined behavior.
--- drivers/media/platform/davinci/isif.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/media/platform/davinci/isif.c +0 -9
@@ -884,9 +884,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params)static int isif_config_ycbcr (void ) {struct isif_ycbcr_config *params = &isif_cfg.ycbcr; -struct vpss_pg_frame_size frame_size;u32 modeset =0 , ccdcfg =0 ; -struct vpss_sync_pol sync;dev_dbg (isif_cfg.dev,"\nStarting isif_config_ycbcr..." );
@@ -974,13 +972,6 @@ static int isif_config_ycbcr(void)/* two fields are interleaved in memory */ regw (0x00000249 ,SDOFST ); -/* Setup test pattern if enabled */ -if (isif_cfg.bayer.config_params.test_pat_gen) { - sync.ccdpg_hdpol = params->hd_pol; - sync.ccdpg_vdpol = params->vd_pol; -dm365_vpss_set_sync_pol (sync); -dm365_vpss_set_pg_frame_size (frame_size); - }return 0 ; }
Signature · 1 line
2.20.0
Quoted 22 lines · Arnd Bergmann
clang warns about a possible variable use that gcc never complained about:
drivers/media/platform/davinci/isif.c:982:32: error: variable 'frame_size' is uninitialized when used here[-Werror,-Wuninitialized] dm365_vpss_set_pg_frame_size(frame_size); ^~~~~~~~~~ drivers/media/platform/davinci/isif.c:887:2: note: variable 'frame_size' is declared here struct vpss_pg_frame_size frame_size; ^1 error generated.
There is no initialization for this variable at all, and there has never been one in the mainline kernel, so we really should not put that stack data into an mmio register.
On the other hand, I suspect that gcc checks the condition more closely and notices that the global isif_cfg.bayer.config_params.test_pat_gen flag is initialized to zero and never written to from any code path, so anything depending on it can be eliminated.
Quoted 6 lines
To shut up the clang warning, just remove the dead code manually, it has probably never been used because any attempt to do so would have resulted in undefined behavior.
Fixes 63e3ab142fa3 ("V4L/DVB: V4L - vpfe capture - source for ISIF driver on DM365")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 35 lines
--- drivers/media/platform/davinci/isif.c | 9 --------- 1 file changed, 9 deletions(-)drivers/media/platform/davinci/isif.c +0
-9@@ -884,9 +884,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params)static int isif_config_ycbcr (void ) {struct isif_ycbcr_config *params = &isif_cfg.ycbcr; -struct vpss_pg_frame_size frame_size;u32 modeset =0 , ccdcfg =0 ; -struct vpss_sync_pol sync;dev_dbg (isif_cfg.dev,"\nStarting isif_config_ycbcr..." );@@ -974,13 +972,6 @@ static int isif_config_ycbcr(void)/* two fields are interleaved in memory */ regw (0x00000249 ,SDOFST ); -/* Setup test pattern if enabled */ -if (isif_cfg.bayer.config_params.test_pat_gen) { - sync.ccdpg_hdpol = params->hd_pol; - sync.ccdpg_vdpol = params->vd_pol; -dm365_vpss_set_sync_pol (sync); -dm365_vpss_set_pg_frame_size (frame_size); - }return 0 ; }Signature · 1 line
2.20.0
Quoted 27 lines · Arnd Bergmann
clang warns about a possible variable use that gcc never complained about:
drivers/media/platform/davinci/isif.c:982:32: error: variable 'frame_size' is uninitialized when used here[-Werror,-Wuninitialized] dm365_vpss_set_pg_frame_size(frame_size); ^~~~~~~~~~ drivers/media/platform/davinci/isif.c:887:2: note: variable 'frame_size' is declared here struct vpss_pg_frame_size frame_size; ^1 error generated.
There is no initialization for this variable at all, and there has never been one in the mainline kernel, so we really should not put that stack data into an mmio register.
On the other hand, I suspect that gcc checks the condition more closely and notices that the global isif_cfg.bayer.config_params.test_pat_gen flag is initialized to zero and never written to from any code path, so anything depending on it can be eliminated.
To shut up the clang warning, just remove the dead code manually, it has probably never been used because any attempt to do so would have resulted in undefined behavior.
Quoted 6 lines
Fixes 63e3ab142fa3 ("V4L/DVB: V4L - vpfe capture - source for ISIF driver on DM365")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/media/platform/davinci/isif.c | 9 --------- 1 file changed, 9 deletions(-)
Cheers,
--Prabhakar Lad
Quoted 31 lines
drivers/media/platform/davinci/isif.c +0
-10@@ -884,9 +884,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params)static int isif_config_ycbcr (void ) {struct isif_ycbcr_config *params = &isif_cfg.ycbcr; -struct vpss_pg_frame_size frame_size;u32 modeset =0 , ccdcfg =0 ; -struct vpss_sync_pol sync;dev_dbg (isif_cfg.dev,"\nStarting isif_config_ycbcr..." );@@ -974,13 +972,6 @@ static int isif_config_ycbcr(void)/* two fields are interleaved in memory */ regw (0x00000249 ,SDOFST ); -/* Setup test pattern if enabled */ -if (isif_cfg.bayer.config_params.test_pat_gen) { - sync.ccdpg_hdpol = params->hd_pol; - sync.ccdpg_vdpol = params->vd_pol; -dm365_vpss_set_sync_pol (sync); -dm365_vpss_set_pg_frame_size (frame_size); - }return 0 ; } --2.20.0