[libcamera-devel,v1] qcam: Remove redundant check
diff mbox series

Message ID 20230502175551.70018-1-pobrn@protonmail.com
State Accepted
Headers show
Series
  • [libcamera-devel,v1] qcam: Remove redundant check
Related show

Commit Message

Barnabás Pőcze May 2, 2023, 5:55 p.m. UTC
The switch statement checks `roles.size()` with cases for 1 and 2,
so in the `default` branch, `role.size() > 2`, i.e. it is always
different from 1, so the check is unnecessary.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 src/apps/qcam/main_window.cpp | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

--
2.40.1

Comments

Jacopo Mondi May 3, 2023, 7:06 a.m. UTC | #1
Hi Barnabás

On Tue, May 02, 2023 at 05:55:53PM +0000, Barnabás Pőcze via libcamera-devel wrote:
> The switch statement checks `roles.size()` with cases for 1 and 2,
> so in the `default` branch, `role.size() > 2`, i.e. it is always
> different from 1, so the check is unnecessary.
>
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

Indeed!
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

Thanks
  j

> ---
>  src/apps/qcam/main_window.cpp | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
> index fb2db4aa..680668df 100644
> --- a/src/apps/qcam/main_window.cpp
> +++ b/src/apps/qcam/main_window.cpp
> @@ -381,11 +381,8 @@ int MainWindow::startCapture()
>  		}
>  		break;
>  	default:
> -		if (roles.size() != 1) {
> -			qWarning() << "Unsupported stream configuration";
> -			return -EINVAL;
> -		}
> -		break;
> +		qWarning() << "Unsupported stream configuration";
> +		return -EINVAL;
>  	}
>
>  	/* Configure the camera. */
> --
> 2.40.1
>
>
Umang Jain May 3, 2023, 7:16 a.m. UTC | #2
Hi,

On 5/2/23 11:25 PM, Barnabás Pőcze via libcamera-devel wrote:
> The switch statement checks `roles.size()` with cases for 1 and 2,
> so in the `default` branch, `role.size() > 2`, i.e. it is always
> different from 1, so the check is unnecessary.
>
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>

Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

> ---
>   src/apps/qcam/main_window.cpp | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
> index fb2db4aa..680668df 100644
> --- a/src/apps/qcam/main_window.cpp
> +++ b/src/apps/qcam/main_window.cpp
> @@ -381,11 +381,8 @@ int MainWindow::startCapture()
>   		}
>   		break;
>   	default:
> -		if (roles.size() != 1) {
> -			qWarning() << "Unsupported stream configuration";
> -			return -EINVAL;
> -		}
> -		break;
> +		qWarning() << "Unsupported stream configuration";
> +		return -EINVAL;
>   	}
>
>   	/* Configure the camera. */
> --
> 2.40.1
>
>
Barnabás Pőcze May 3, 2023, 12:37 p.m. UTC | #3
I am now thinking that maybe the subject should be changed from

  qcam:

to

  apps: qcam:

I checked the output of `git log src/apps/qcam` but there was not a lot to go by.
Should I resend? Or could someone change it if the second version is preferable
when applying?


2023. május 2., kedd 19:55 keltezéssel, Barnabás Pőcze <pobrn@protonmail.com> írta:

> The switch statement checks `roles.size()` with cases for 1 and 2,
> so in the `default` branch, `role.size() > 2`, i.e. it is always
> different from 1, so the check is unnecessary.
> 
> Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
> ---
>  src/apps/qcam/main_window.cpp | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
> index fb2db4aa..680668df 100644
> --- a/src/apps/qcam/main_window.cpp
> +++ b/src/apps/qcam/main_window.cpp
> @@ -381,11 +381,8 @@ int MainWindow::startCapture()
>  		}
>  		break;
>  	default:
> -		if (roles.size() != 1) {
> -			qWarning() << "Unsupported stream configuration";
> -			return -EINVAL;
> -		}
> -		break;
> +		qWarning() << "Unsupported stream configuration";
> +		return -EINVAL;
>  	}
> 
>  	/* Configure the camera. */
> --
> 2.40.1
Jacopo Mondi May 3, 2023, 2:04 p.m. UTC | #4
Hi Barnabás

On Wed, May 03, 2023 at 12:37:49PM +0000, Barnabás Pőcze via libcamera-devel wrote:
> I am now thinking that maybe the subject should be changed from
>
>   qcam:
>
> to
>
>   apps: qcam:
>
> I checked the output of `git log src/apps/qcam` but there was not a lot to go by.
> Should I resend? Or could someone change it if the second version is preferable
> when applying?

No worries, I had already update it and I plan to push it later
today

>
>
> 2023. május 2., kedd 19:55 keltezéssel, Barnabás Pőcze <pobrn@protonmail.com> írta:
>
> > The switch statement checks `roles.size()` with cases for 1 and 2,
> > so in the `default` branch, `role.size() > 2`, i.e. it is always
> > different from 1, so the check is unnecessary.
> >
> > Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
> > ---
> >  src/apps/qcam/main_window.cpp | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
> > index fb2db4aa..680668df 100644
> > --- a/src/apps/qcam/main_window.cpp
> > +++ b/src/apps/qcam/main_window.cpp
> > @@ -381,11 +381,8 @@ int MainWindow::startCapture()
> >  		}
> >  		break;
> >  	default:
> > -		if (roles.size() != 1) {
> > -			qWarning() << "Unsupported stream configuration";
> > -			return -EINVAL;
> > -		}
> > -		break;
> > +		qWarning() << "Unsupported stream configuration";
> > +		return -EINVAL;
> >  	}
> >
> >  	/* Configure the camera. */
> > --
> > 2.40.1

Patch
diff mbox series

diff --git a/src/apps/qcam/main_window.cpp b/src/apps/qcam/main_window.cpp
index fb2db4aa..680668df 100644
--- a/src/apps/qcam/main_window.cpp
+++ b/src/apps/qcam/main_window.cpp
@@ -381,11 +381,8 @@  int MainWindow::startCapture()
 		}
 		break;
 	default:
-		if (roles.size() != 1) {
-			qWarning() << "Unsupported stream configuration";
-			return -EINVAL;
-		}
-		break;
+		qWarning() << "Unsupported stream configuration";
+		return -EINVAL;
 	}

 	/* Configure the camera. */