[libcamera-devel,1/2] libcamera: control: define an explicit default ControlInfo constructor
diff mbox series

Message ID 20220821124343.487963-1-Rauch.Christian@gmx.de
State Superseded
Headers show
Series
  • [libcamera-devel,1/2] libcamera: control: define an explicit default ControlInfo constructor
Related show

Commit Message

Christian Rauch Aug. 21, 2022, 12:43 p.m. UTC
The default ControlInfo constructor allowed to partially initialised the
min/max/def values. Add an explicit default constructor in order to enforce
that either all or none of the min/max/def values are defined.

Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
---
 include/libcamera/controls.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

--
2.34.1

Comments

Kieran Bingham Aug. 22, 2022, 9:37 p.m. UTC | #1
Hi Christian,

Quoting Christian Rauch via libcamera-devel (2022-08-21 13:43:42)
> The default ControlInfo constructor allowed to partially initialised the
> min/max/def values. Add an explicit default constructor in order to enforce
> that either all or none of the min/max/def values are defined.
> 

I think this would break bisection, so would have to have the follow up
2/2 patch merged all in one commit.


> Signed-off-by: Christian Rauch <Rauch.Christian@gmx.de>
> ---
>  include/libcamera/controls.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
> index ebc168fc..214ad7f3 100644
> --- a/include/libcamera/controls.h
> +++ b/include/libcamera/controls.h
> @@ -268,9 +268,10 @@ private:
>  class ControlInfo
>  {
>  public:
> -       explicit ControlInfo(const ControlValue &min = 0,
> -                            const ControlValue &max = 0,
> -                            const ControlValue &def = 0);
> +       explicit ControlInfo() = default;
> +       explicit ControlInfo(const ControlValue &min,
> +                            const ControlValue &max,
> +                            const ControlValue &def);

I think I agree it can be better to be explicit, but I'm weary that
skimming the next patch - some times there isn't a reasonable default.

That makes me fear we'd need to <optional> the default ... and I start
fearing how templated things might get ...

Now to the next patch...
--
Kieran

>         explicit ControlInfo(Span<const ControlValue> values,
>                              const ControlValue &def = {});
>         explicit ControlInfo(std::set<bool> values, bool def);
> --
> 2.34.1
>

Patch
diff mbox series

diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index ebc168fc..214ad7f3 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -268,9 +268,10 @@  private:
 class ControlInfo
 {
 public:
-	explicit ControlInfo(const ControlValue &min = 0,
-			     const ControlValue &max = 0,
-			     const ControlValue &def = 0);
+	explicit ControlInfo() = default;
+	explicit ControlInfo(const ControlValue &min,
+			     const ControlValue &max,
+			     const ControlValue &def);
 	explicit ControlInfo(Span<const ControlValue> values,
 			     const ControlValue &def = {});
 	explicit ControlInfo(std::set<bool> values, bool def);