[libcamera-devel] [PATCH v5 03/19] libcamera: geometry: Add 0-initialized SizeRange constructor

Jacopo Mondi jacopo at jmondi.org
Wed Mar 27 09:00:50 CET 2019


Hi Laurent,

On Wed, Mar 27, 2019 at 02:13:35AM +0200, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Tue, Mar 26, 2019 at 09:38:46AM +0100, Jacopo Mondi wrote:
> > Add constructor to SizeRange which initialize all the size range fields
> > to 0.
> >
> > While at there make the in-line constructor declarations respect the
> > coding style by moving braces to a new line.
> >
> > Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
> > ---
> >  src/libcamera/geometry.cpp       | 11 ++++++++++-
> >  src/libcamera/include/geometry.h |  9 ++++++++-
> >  2 files changed, 18 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp
> > index b6b6592bdfec..dbc37ca8e3f4 100644
> > --- a/src/libcamera/geometry.cpp
> > +++ b/src/libcamera/geometry.cpp
> > @@ -57,7 +57,16 @@ namespace libcamera {
> >
> >  /**
> >   * \fn SizeRange::SizeRange()
> > - * \brief Construct a size range
> > + * \brief Construct a size range initialized to 0
> > + */
> > +
> > +/**
> > + * \fn SizeRange::SizeRange(unsigned int minW, unsigned int minH, unsigned int maxW, unsigned int maxH)
> > + * \brief Construct an initialized size range
> > + * \param minW The minimum width
> > + * \param minH The minimum height
> > + * \param maxW The maximum width
> > + * \param maxH The maximum height
> >   */
> >
> >  /**
> > diff --git a/src/libcamera/include/geometry.h b/src/libcamera/include/geometry.h
> > index eadc4ed4f9cb..749746495204 100644
> > --- a/src/libcamera/include/geometry.h
> > +++ b/src/libcamera/include/geometry.h
> > @@ -18,10 +18,17 @@ struct Rectangle {
> >  };
> >
> >  struct SizeRange {
> > +	SizeRange(void)
> > +		: SizeRange(0, 0, 0, 0)
> > +	{
> > +	}
> > +
> >  	SizeRange(unsigned int minW, unsigned int minH,
> >  		  unsigned int maxW, unsigned int maxH)
> >  		: minWidth(minW), minHeight(minH), maxWidth(maxW),
> > -		  maxHeight(maxH) {}
> > +		  maxHeight(maxH)
> > +	{
> > +	}
> >
> >  	unsigned int minWidth;
> >  	unsigned int minHeight;
>
> Open question here, what to you think of
> https://en.cppreference.com/w/cpp/language/data_members#Member_initialization,
> item 2 instead of creating a constructor for this kind of purpose ?

That it might be nice, but I need to declare a default constructor
anyhow.

+       SizeRange() = default;

        SizeRange(unsigned int minW, unsigned int minH,
                  unsigned int maxW, unsigned int maxH)
@@ -34,10 +31,10 @@ struct SizeRange {
        {
        }

-       unsigned int minWidth;
-       unsigned int minHeight;
-       unsigned int maxWidth;
-       unsigned int maxHeight;
+       unsigned int minWidth = 0;
+       unsigned int minHeight = 0;
+       unsigned int maxWidth = 0;
+       unsigned int maxHeight = 0;
 };

I don't have any strong opinion to be honest.

Thanks
  j

>
> --
> Regards,
>
> Laurent Pinchart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20190327/1c23af40/attachment.sig>


More information about the libcamera-devel mailing list