[RFC,v1] apps: cam: Do not overwrite name when adding camera model
diff mbox series

Message ID 20250815142522.2237088-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [RFC,v1] apps: cam: Do not overwrite name when adding camera model
Related show

Commit Message

Barnabás Pőcze Aug. 15, 2025, 2:25 p.m. UTC
If `addModel` is true, then the previously set `name` will be overwritten.
This does not seem to be the intended behaviour, so fix it by using `+=`.

Before:

  Available cameras:
  1: 'imx219' (/base/soc@0/bus@30800000/i2c@30a30000/camera@10)

After:

  Available cameras:
  1: External camera 'imx219' (/base/soc@0/bus@30800000/i2c@30a30000/camera@10)

Fixes: aab49f903e858a ("cam: Do not assume Location is available")
Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/apps/cam/main.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Aug. 15, 2025, 2:37 p.m. UTC | #1
Quoting Barnabás Pőcze (2025-08-15 15:25:22)
> If `addModel` is true, then the previously set `name` will be overwritten.
> This does not seem to be the intended behaviour, so fix it by using `+=`.
> 
> Before:
> 
>   Available cameras:
>   1: 'imx219' (/base/soc@0/bus@30800000/i2c@30a30000/camera@10)
> 
> After:
> 
>   Available cameras:
>   1: External camera 'imx219' (/base/soc@0/bus@30800000/i2c@30a30000/camera@10)
> 

Thank you - it's always so much more helpful when the effects are
clearly documented like that!


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

> Fixes: aab49f903e858a ("cam: Do not assume Location is available")
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/apps/cam/main.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp
> index cbc85b59f..ad6bde68a 100644
> --- a/src/apps/cam/main.cpp
> +++ b/src/apps/cam/main.cpp
> @@ -322,7 +322,7 @@ std::string CamApp::cameraName(const Camera *camera)
>                  */
>                 const auto &model = props.get(properties::Model);
>                 if (model)
> -                       name = "'" + *model + "' ";
> +                       name += "'" + *model + "' ";
>         }
>  
>         name += "(" + camera->id() + ")";
> -- 
> 2.50.1
>

Patch
diff mbox series

diff --git a/src/apps/cam/main.cpp b/src/apps/cam/main.cpp
index cbc85b59f..ad6bde68a 100644
--- a/src/apps/cam/main.cpp
+++ b/src/apps/cam/main.cpp
@@ -322,7 +322,7 @@  std::string CamApp::cameraName(const Camera *camera)
 		 */
 		const auto &model = props.get(properties::Model);
 		if (model)
-			name = "'" + *model + "' ";
+			name += "'" + *model + "' ";
 	}
 
 	name += "(" + camera->id() + ")";