[libcamera-devel,07/10] test: v4l2_videodevice: Prevent variable aliasing of format
diff mbox series

Message ID 20201013151241.3557005-8-kieran.bingham@ideasonboard.com
State Superseded
Headers show
Series
  • Shadowed Variables
Related show

Commit Message

Kieran Bingham Oct. 13, 2020, 3:12 p.m. UTC
Rename the scoped usage of the variable format while iterating the formats
as it aliases the outer scoped format which is used for specific testing.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/v4l2_videodevice/formats.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Niklas Söderlund Oct. 14, 2020, 12:29 p.m. UTC | #1
Hi Kieran,

On 2020-10-13 16:12:38 +0100, Kieran Bingham wrote:
> Rename the scoped usage of the variable format while iterating the formats
> as it aliases the outer scoped format which is used for specific testing.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  test/v4l2_videodevice/formats.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/test/v4l2_videodevice/formats.cpp b/test/v4l2_videodevice/formats.cpp
> index 043732dcaba1..e3283cf92bff 100644
> --- a/test/v4l2_videodevice/formats.cpp
> +++ b/test/v4l2_videodevice/formats.cpp
> @@ -55,10 +55,10 @@ protected:
>  			{ V4L2_PIX_FMT_Y16_BE, "Y16 -BE" }
>  		};
>  
> -		for (const auto &format : formats) {
> -			if (V4L2PixelFormat(format.first).toString() != format.second) {
> +		for (const auto &fmt : formats) {
> +			if (V4L2PixelFormat(fmt.first).toString() != fmt.second) {
>  				cerr << "Failed to convert V4L2PixelFormat"
> -				     << utils::hex(format.first) << "to string"
> +				     << utils::hex(fmt.first) << "to string"
>  				     << endl;
>  				return TestFail;
>  			}
> -- 
> 2.25.1
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Oct. 15, 2020, 1:39 p.m. UTC | #2
Hi Kieran,

Thank you for the patch.

On Tue, Oct 13, 2020 at 04:12:38PM +0100, Kieran Bingham wrote:
> Rename the scoped usage of the variable format while iterating the formats
> as it aliases the outer scoped format which is used for specific testing.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

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

> ---
>  test/v4l2_videodevice/formats.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/test/v4l2_videodevice/formats.cpp b/test/v4l2_videodevice/formats.cpp
> index 043732dcaba1..e3283cf92bff 100644
> --- a/test/v4l2_videodevice/formats.cpp
> +++ b/test/v4l2_videodevice/formats.cpp
> @@ -55,10 +55,10 @@ protected:
>  			{ V4L2_PIX_FMT_Y16_BE, "Y16 -BE" }
>  		};
>  
> -		for (const auto &format : formats) {
> -			if (V4L2PixelFormat(format.first).toString() != format.second) {
> +		for (const auto &fmt : formats) {
> +			if (V4L2PixelFormat(fmt.first).toString() != fmt.second) {
>  				cerr << "Failed to convert V4L2PixelFormat"
> -				     << utils::hex(format.first) << "to string"
> +				     << utils::hex(fmt.first) << "to string"
>  				     << endl;
>  				return TestFail;
>  			}

Patch
diff mbox series

diff --git a/test/v4l2_videodevice/formats.cpp b/test/v4l2_videodevice/formats.cpp
index 043732dcaba1..e3283cf92bff 100644
--- a/test/v4l2_videodevice/formats.cpp
+++ b/test/v4l2_videodevice/formats.cpp
@@ -55,10 +55,10 @@  protected:
 			{ V4L2_PIX_FMT_Y16_BE, "Y16 -BE" }
 		};
 
-		for (const auto &format : formats) {
-			if (V4L2PixelFormat(format.first).toString() != format.second) {
+		for (const auto &fmt : formats) {
+			if (V4L2PixelFormat(fmt.first).toString() != fmt.second) {
 				cerr << "Failed to convert V4L2PixelFormat"
-				     << utils::hex(format.first) << "to string"
+				     << utils::hex(fmt.first) << "to string"
 				     << endl;
 				return TestFail;
 			}