[1/2] tw686x: fix sparse warning
Commit Message
From: Hans Verkuil <hans.verkuil@cisco.com>
tw686x-video.c: In function 'tw686x_video_init':
tw686x-video.c:65:543: warning: array subscript is above array bounds [-Warray-bounds]
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
drivers/media/pci/tw686x/tw686x-video.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
Comments
On 21 Apr 08:50 AM, Hans Verkuil wrote:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> tw686x-video.c: In function 'tw686x_video_init':
> tw686x-video.c:65:543: warning: array subscript is above array bounds [-Warray-bounds]
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Thanks,
> ---
> drivers/media/pci/tw686x/tw686x-video.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c
> index 118e9fa..9a31de9 100644
> --- a/drivers/media/pci/tw686x/tw686x-video.c
> +++ b/drivers/media/pci/tw686x/tw686x-video.c
> @@ -60,10 +60,11 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, unsigned int fps)
> 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
> 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
> };
> + unsigned int max_fps = (std & V4L2_STD_525_60) ? 30 : 25;
> + unsigned int i;
>
> - unsigned int i =
> - (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
> -
> + fps = fps > max_fps ? max_fps : fps;
> + i = (std & V4L2_STD_525_60) ? std_625_50[fps] : std_525_60[fps];
> return map[i];
> }
>
> --
> 2.8.0.rc3
>
@@ -60,10 +60,11 @@ static unsigned int tw686x_fields_map(v4l2_std_id std, unsigned int fps)
0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 0, 0
};
+ unsigned int max_fps = (std & V4L2_STD_525_60) ? 30 : 25;
+ unsigned int i;
- unsigned int i =
- (std & V4L2_STD_625_50) ? std_625_50[fps] : std_525_60[fps];
-
+ fps = fps > max_fps ? max_fps : fps;
+ i = (std & V4L2_STD_525_60) ? std_625_50[fps] : std_525_60[fps];
return map[i];
}