[libcamera-devel,5/7] libcamera: v4l2_device: Zero-initialize V4L2 format

Message ID 20190201154248.15006-6-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: v4l2_device: Address comments for s/g_fmt
Related show

Commit Message

Jacopo Mondi Feb. 1, 2019, 3:42 p.m. UTC
Zero initialize v4l2_format structures used to set and get format on the
V4L2 device.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/v4l2_device.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Kieran Bingham Feb. 1, 2019, 9:31 p.m. UTC | #1
Hi Jacopo,

On 01/02/2019 16:42, Jacopo Mondi wrote:
> Zero initialize v4l2_format structures used to set and get format on the
> V4L2 device.

Because this one could also cause undesired behaviour, I think this too
deserves a fixes tag:

Fixes: ba8da0f2fcd0 ("libcamera: v4l2_device: Add methods to get/set
format")

Otherwise,

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> ---
>  src/libcamera/v4l2_device.cpp | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 0d4d60f..b86a629 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -299,7 +299,7 @@ int V4L2Device::setFormat(V4L2DeviceFormat *format)
>  
>  int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
>  	int ret;
>  
> @@ -323,7 +323,7 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
>  
>  int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
>  	int ret;
>  
> @@ -344,7 +344,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
>  
>  int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
>  	int ret;
>  
> @@ -371,7 +371,7 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
>  
>  int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
>  	int ret;
>  
>
Laurent Pinchart Feb. 1, 2019, 10:35 p.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Fri, Feb 01, 2019 at 04:42:46PM +0100, Jacopo Mondi wrote:
> Zero initialize v4l2_format structures used to set and get format on the
> V4L2 device.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/libcamera/v4l2_device.cpp | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
> index 0d4d60f..b86a629 100644
> --- a/src/libcamera/v4l2_device.cpp
> +++ b/src/libcamera/v4l2_device.cpp
> @@ -299,7 +299,7 @@ int V4L2Device::setFormat(V4L2DeviceFormat *format)
>  
>  int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
>  	int ret;
>  
> @@ -323,7 +323,7 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
>  
>  int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
>  	int ret;
>  
> @@ -344,7 +344,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
>  
>  int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
>  	int ret;
>  
> @@ -371,7 +371,7 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
>  
>  int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
>  {
> -	struct v4l2_format v4l2Format;
> +	struct v4l2_format v4l2Format = {};
>  	struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
>  	int ret;
>

Patch

diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 0d4d60f..b86a629 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -299,7 +299,7 @@  int V4L2Device::setFormat(V4L2DeviceFormat *format)
 
 int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
 {
-	struct v4l2_format v4l2Format;
+	struct v4l2_format v4l2Format = {};
 	struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
 	int ret;
 
@@ -323,7 +323,7 @@  int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
 
 int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
 {
-	struct v4l2_format v4l2Format;
+	struct v4l2_format v4l2Format = {};
 	struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
 	int ret;
 
@@ -344,7 +344,7 @@  int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
 
 int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
 {
-	struct v4l2_format v4l2Format;
+	struct v4l2_format v4l2Format = {};
 	struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
 	int ret;
 
@@ -371,7 +371,7 @@  int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
 
 int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
 {
-	struct v4l2_format v4l2Format;
+	struct v4l2_format v4l2Format = {};
 	struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
 	int ret;