[libcamera-devel,3/4] cam: fix use of uninitialized field

Message ID 20201007092239.41704-3-tomi.valkeinen@iki.fi
State Accepted
Headers show
Series
  • [libcamera-devel,1/4] cam: options: fix access to uninit variable
Related show

Commit Message

Tomi Valkeinen Oct. 7, 2020, 9:22 a.m. UTC
Initialize last_ to 0 to avoid uninitialized use.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
---
 src/cam/capture.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Oct. 7, 2020, 9:48 a.m. UTC | #1
Hi Tomi,

On 07/10/2020 10:22, Tomi Valkeinen wrote:
> Initialize last_ to 0 to avoid uninitialized use.
> 

Indeed, I suspect we have more uninitialised class members that need
sorting too, we have quite a few reported by coverity. Some of course
aren't essential, but I almost prefer initialising everything ;-)

But this one is indeed an uninitialised access in Capture::requestComplete.

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

I guess we could add a fixes tag, but it doesn't really matter ;-)
There's no backporting happening here ;-)

> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
> ---
>  src/cam/capture.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 5510c00..995614a 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -17,7 +17,7 @@ using namespace libcamera;
>  
>  Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
>  		 EventLoop *loop)
> -	: camera_(camera), config_(config), writer_(nullptr), loop_(loop),
> +	: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
>  	  captureCount_(0), captureLimit_(0)
>  {
>  }
>
Laurent Pinchart Oct. 7, 2020, 1:30 p.m. UTC | #2
Hi Tomi,

Thank you for the patch.

On Wed, Oct 07, 2020 at 12:22:38PM +0300, Tomi Valkeinen wrote:
> Initialize last_ to 0 to avoid uninitialized use.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>

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

> ---
>  src/cam/capture.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 5510c00..995614a 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -17,7 +17,7 @@ using namespace libcamera;
>  
>  Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
>  		 EventLoop *loop)
> -	: camera_(camera), config_(config), writer_(nullptr), loop_(loop),
> +	: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
>  	  captureCount_(0), captureLimit_(0)
>  {
>  }
Niklas Söderlund Oct. 7, 2020, 4:05 p.m. UTC | #3
Hi Tomi,

Thanks for your work.

On 2020-10-07 12:22:38 +0300, Tomi Valkeinen wrote:
> Initialize last_ to 0 to avoid uninitialized use.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/cam/capture.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 5510c00..995614a 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -17,7 +17,7 @@ using namespace libcamera;
>  
>  Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
>  		 EventLoop *loop)
> -	: camera_(camera), config_(config), writer_(nullptr), loop_(loop),
> +	: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
>  	  captureCount_(0), captureLimit_(0)
>  {
>  }
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
index 5510c00..995614a 100644
--- a/src/cam/capture.cpp
+++ b/src/cam/capture.cpp
@@ -17,7 +17,7 @@  using namespace libcamera;
 
 Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,
 		 EventLoop *loop)
-	: camera_(camera), config_(config), writer_(nullptr), loop_(loop),
+	: camera_(camera), config_(config), writer_(nullptr), last_(0), loop_(loop),
 	  captureCount_(0), captureLimit_(0)
 {
 }