[libcamera-devel,1/5] test: timer: Initialise all variables

Message ID 20190117202043.21420-2-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • General fixes
Related show

Commit Message

Kieran Bingham Jan. 17, 2019, 8:20 p.m. UTC
The ManagedTimer does not initialise the integer 'interval_' variable.

This is set before used, and should not break - but for completeness
(and to cover static analysers) initialise the variable in the
initialiser list.

Fixes: 034ea868027d ("test: Add timer test")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/timer.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Jan. 17, 2019, 8:30 p.m. UTC | #1
Hi Kieran,

Thank you for the patch.

On Thu, Jan 17, 2019 at 08:20:39PM +0000, Kieran Bingham wrote:
> The ManagedTimer does not initialise the integer 'interval_' variable.
> 
> This is set before used, and should not break - but for completeness
> (and to cover static analysers) initialise the variable in the
> initialiser list.
> 
> Fixes: 034ea868027d ("test: Add timer test")
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  test/timer.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/test/timer.cpp b/test/timer.cpp
> index 6a3cda70bef4..3d1a78ac2768 100644
> --- a/test/timer.cpp
> +++ b/test/timer.cpp
> @@ -19,7 +19,8 @@ using namespace libcamera;
>  class ManagedTimer : public Timer
>  {
>  public:
> -	ManagedTimer() : Timer()
> +	ManagedTimer() :
> +		Timer(), interval_(0)

Nitpicking, this should read

	ManagedTimer()
		: Timer(), interval_(0)

Apart from that,

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

>  	{
>  		timeout.connect(this, &ManagedTimer::timeoutHandler);
>  	}
Kieran Bingham Jan. 17, 2019, 8:31 p.m. UTC | #2
Hi Laurent,

On 17/01/2019 20:30, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Thu, Jan 17, 2019 at 08:20:39PM +0000, Kieran Bingham wrote:
>> The ManagedTimer does not initialise the integer 'interval_' variable.
>>
>> This is set before used, and should not break - but for completeness
>> (and to cover static analysers) initialise the variable in the
>> initialiser list.
>>
>> Fixes: 034ea868027d ("test: Add timer test")
>> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
>> ---
>>  test/timer.cpp | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/test/timer.cpp b/test/timer.cpp
>> index 6a3cda70bef4..3d1a78ac2768 100644
>> --- a/test/timer.cpp
>> +++ b/test/timer.cpp
>> @@ -19,7 +19,8 @@ using namespace libcamera;
>>  class ManagedTimer : public Timer
>>  {
>>  public:
>> -	ManagedTimer() : Timer()
>> +	ManagedTimer() :
>> +		Timer(), interval_(0)
> 
> Nitpicking, this should read
> 
> 	ManagedTimer()
> 		: Timer(), interval_(0)

Aha, I can fix this before pushing.


> 
> Apart from that,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Thanks.


> 
>>  	{
>>  		timeout.connect(this, &ManagedTimer::timeoutHandler);
>>  	}
>
Niklas Söderlund Jan. 17, 2019, 9:57 p.m. UTC | #3
Hi Kieran,

Thanks for your work.

On 2019-01-17 20:20:39 +0000, Kieran Bingham wrote:
> The ManagedTimer does not initialise the integer 'interval_' variable.
> 
> This is set before used, and should not break - but for completeness
> (and to cover static analysers) initialise the variable in the
> initialiser list.
> 
> Fixes: 034ea868027d ("test: Add timer test")
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

With the comment Laurent points out fixed,

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

> ---
>  test/timer.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/test/timer.cpp b/test/timer.cpp
> index 6a3cda70bef4..3d1a78ac2768 100644
> --- a/test/timer.cpp
> +++ b/test/timer.cpp
> @@ -19,7 +19,8 @@ using namespace libcamera;
>  class ManagedTimer : public Timer
>  {
>  public:
> -	ManagedTimer() : Timer()
> +	ManagedTimer() :
> +		Timer(), interval_(0)
>  	{
>  		timeout.connect(this, &ManagedTimer::timeoutHandler);
>  	}
> -- 
> 2.17.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/test/timer.cpp b/test/timer.cpp
index 6a3cda70bef4..3d1a78ac2768 100644
--- a/test/timer.cpp
+++ b/test/timer.cpp
@@ -19,7 +19,8 @@  using namespace libcamera;
 class ManagedTimer : public Timer
 {
 public:
-	ManagedTimer() : Timer()
+	ManagedTimer() :
+		Timer(), interval_(0)
 	{
 		timeout.connect(this, &ManagedTimer::timeoutHandler);
 	}