[libcamera-devel,2/2] Explicit cast to int
diff mbox series

Message ID 20220421172549.138360-2-utkarsh02t@gmail.com
State Rejected
Headers show
Series
  • [libcamera-devel,1/2] Support float data type in options
Related show

Commit Message

Utkarsh Tiwari April 21, 2022, 5:25 p.m. UTC
After introduction of float values to options the conversion of unsigned int to int or vice versa is regarded as the same rank as conversion to and from float. Fix this by using an explicit cast
---
 src/cam/stream_options.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kieran Bingham April 25, 2022, 4 p.m. UTC | #1
Quoting Utkarsh Tiwari via libcamera-devel (2022-04-21 18:25:49)
> After introduction of float values to options the conversion of unsigned int to int or vice versa is regarded as the same rank as conversion to and from float. Fix this by using an explicit cast

As discussed on IRC, this patch probably needs to be first. Adjust the
commit message to say "In order to be able to use float values..." or
such.

Also - please wrap the message, and make sure you add your
Signed-off-by: tag.

--
Kieran


> ---
>  src/cam/stream_options.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp
> index 150bd27c..83d216b7 100644
> --- a/src/cam/stream_options.cpp
> +++ b/src/cam/stream_options.cpp
> @@ -90,8 +90,8 @@ int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config,
>                 StreamConfiguration &cfg = config->at(i++);
>  
>                 if (opts.isSet("width") && opts.isSet("height")) {
> -                       cfg.size.width = opts["width"];
> -                       cfg.size.height = opts["height"];
> +                       cfg.size.width = static_cast<int>(opts["width"]);
> +                       cfg.size.height = static_cast<int>(opts["height"]);
>                 }
>  
>                 if (opts.isSet("pixelformat"))
> -- 
> 2.25.1
>

Patch
diff mbox series

diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp
index 150bd27c..83d216b7 100644
--- a/src/cam/stream_options.cpp
+++ b/src/cam/stream_options.cpp
@@ -90,8 +90,8 @@  int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config,
 		StreamConfiguration &cfg = config->at(i++);
 
 		if (opts.isSet("width") && opts.isSet("height")) {
-			cfg.size.width = opts["width"];
-			cfg.size.height = opts["height"];
+			cfg.size.width = static_cast<int>(opts["width"]);
+			cfg.size.height = static_cast<int>(opts["height"]);
 		}
 
 		if (opts.isSet("pixelformat"))