[libcamera-devel] libcamera: pipeline: ipu3: Fix compilation on gcc 5 and 6

Message ID 20200327193424.13221-1-laurent.pinchart@ideasonboard.com
State Accepted
Commit 8f8992e4ee181f1efba3b8ab5eb680e425bf1b12
Headers show
Series
  • [libcamera-devel] libcamera: pipeline: ipu3: Fix compilation on gcc 5 and 6
Related show

Commit Message

Laurent Pinchart March 27, 2020, 7:34 p.m. UTC
Commit 5e7c5d64a67f ("libcamera: ipu3: Do not unconditionally queue
buffers to CIO2") introduced usage of the std::queue default constructor
by using copy-list-initialization from {}. The default constructor was
explicit in C++11, which was fixed retroactively with a defect report
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html).
gcc 5 and 6 are unfortunately affected, requiring explicit usage of the
constructor.

Fixes: 5e7c5d64a67f ("libcamera: ipu3: Do not unconditionally queue buffers to CIO2")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Niklas Söderlund March 27, 2020, 8:01 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2020-03-27 21:34:24 +0200, Laurent Pinchart wrote:
> Commit 5e7c5d64a67f ("libcamera: ipu3: Do not unconditionally queue
> buffers to CIO2") introduced usage of the std::queue default constructor
> by using copy-list-initialization from {}. The default constructor was
> explicit in C++11, which was fixed retroactively with a defect report
> (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html).
> gcc 5 and 6 are unfortunately affected, requiring explicit usage of the
> constructor.
> 
> Fixes: 5e7c5d64a67f ("libcamera: ipu3: Do not unconditionally queue buffers to CIO2")
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index b490a801a9c4..1e114ca7ed10 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -1532,7 +1532,8 @@ int CIO2Device::allocateBuffers()
>  
>  void CIO2Device::freeBuffers()
>  {
> -	availableBuffers_ = {};
> +	/* The default std::queue constructor is explicit with gcc 5 and 6. */

I'm not sure the comment is needed, no biggie. With or without it,

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> +	availableBuffers_ = std::queue<FrameBuffer *>{};
>  
>  	buffers_.clear();
>  
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart March 27, 2020, 8:10 p.m. UTC | #2
Hi Niklas,

On Fri, Mar 27, 2020 at 09:01:42PM +0100, Niklas Söderlund wrote:
> On 2020-03-27 21:34:24 +0200, Laurent Pinchart wrote:
> > Commit 5e7c5d64a67f ("libcamera: ipu3: Do not unconditionally queue
> > buffers to CIO2") introduced usage of the std::queue default constructor
> > by using copy-list-initialization from {}. The default constructor was
> > explicit in C++11, which was fixed retroactively with a defect report
> > (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html).
> > gcc 5 and 6 are unfortunately affected, requiring explicit usage of the
> > constructor.
> > 
> > Fixes: 5e7c5d64a67f ("libcamera: ipu3: Do not unconditionally queue buffers to CIO2")
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/libcamera/pipeline/ipu3/ipu3.cpp | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > index b490a801a9c4..1e114ca7ed10 100644
> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > @@ -1532,7 +1532,8 @@ int CIO2Device::allocateBuffers()
> >  
> >  void CIO2Device::freeBuffers()
> >  {
> > -	availableBuffers_ = {};
> > +	/* The default std::queue constructor is explicit with gcc 5 and 6. */
> 
> I'm not sure the comment is needed, no biggie. With or without it,

It's in the git log, but I've added it here to remind us that we could
simplify the code when we'll drop support for gcc 5 and 6 :-)

> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> 
> > +	availableBuffers_ = std::queue<FrameBuffer *>{};
> >  
> >  	buffers_.clear();
> >

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index b490a801a9c4..1e114ca7ed10 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -1532,7 +1532,8 @@  int CIO2Device::allocateBuffers()
 
 void CIO2Device::freeBuffers()
 {
-	availableBuffers_ = {};
+	/* The default std::queue constructor is explicit with gcc 5 and 6. */
+	availableBuffers_ = std::queue<FrameBuffer *>{};
 
 	buffers_.clear();